Import jest-axe matchers via setupFilesAfterEnv config property (#8217)

* Now expect is extended for jest-axe via the jest setupFilesAfterEnv config property.

* Renamed a test setup file for jest.
This commit is contained in:
Nick Taylor 2020-06-01 10:37:32 -04:00 committed by GitHub
parent 699f9c8144
commit a72831b952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import { h } from 'preact';
import { deep } from 'preact-render-spy';
import fetch from 'jest-fetch-mock';
import { axe, toHaveNoViolations } from 'jest-axe';
import { axe } from 'jest-axe';
import Onboarding from '../Onboarding';
import ProfileForm from '../components/ProfileForm';
@ -53,9 +53,6 @@ function expectStepperToRender(onboardingSlides, activeDotCount) {
}
describe('<Onboarding />', () => {
beforeAll(() => {
expect.extend(toHaveNoViolations);
});
beforeEach(() => {
fetch.resetMocks();
});

View file

@ -6,6 +6,7 @@
process.env.TZ = 'UTC';
module.exports = {
setupFilesAfterEnv: ['./testSetup.js'],
collectCoverageFrom: [
'app/javascript/**/*.{js,jsx}',
// This exclusion avoids running coverage on Barrel files, https://twitter.com/housecor/status/981558704708472832

1
testSetup.js Normal file
View file

@ -0,0 +1 @@
import 'jest-axe/extend-expect';