forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Jest testing framework for unit tests
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
- Loading branch information
Showing
8 changed files
with
451 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
build | ||
public | ||
serviceWorker.js | ||
serviceWorker.js | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules/ | ||
build/ | ||
coverage/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { shallow } from 'enzyme' | ||
|
||
import { GovBanner } from '@trussworks/react-uswds' | ||
import App from './App' | ||
|
||
test('renders learn react link', () => { | ||
const { getByText } = render(<App />) | ||
const linkElement = getByText(/learn react/i) | ||
expect(linkElement).toBeInTheDocument() | ||
describe('App.js', () => { | ||
it('renders the Gov Banner', () => { | ||
const wrapper = shallow(<App />) | ||
expect(wrapper.find(GovBanner)).toExist() | ||
}) | ||
it('renders a welcome message', () => { | ||
const wrapper = shallow(<App />) | ||
expect(wrapper.find('h1')).toIncludeText('Welcome to TDRS!') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
|
||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect' | ||
import 'jest-enzyme' | ||
import Enzyme from 'enzyme' | ||
import Adapter from 'enzyme-adapter-react-16' | ||
|
||
Enzyme.configure({ adapter: new Adapter() }) |
Oops, something went wrong.