-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add e2e testing + e2e accessibility test (#7688)
* add accessibility workflow * Update name * fix function name * add light mode/dark mode testing, clean up logging * add some pages to show violations * add spacing * revert page changes * feat: add e2e testing * endline * test css change that fails e2e test * revert test css change * test css change * revert css change * remove transformIgnorePatterns
- Loading branch information
Showing
7 changed files
with
292 additions
and
31 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { AxePuppeteer } = require('@axe-core/puppeteer'); | ||
|
||
const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); | ||
|
||
describe('home page', () => { | ||
beforeAll(async () => { | ||
await page.goto(`http://localhost:3000/`); | ||
await page.waitForSelector('h1'); | ||
}); | ||
|
||
it('should display the home page with no accessibility violations', async () => { | ||
const results = await new AxePuppeteer(page).analyze(); | ||
expect(results.violations).toHaveLength(0); | ||
}); | ||
|
||
it('should display the home page with no accessibility violations in dark mode', async () => { | ||
await page.click('button[title="Dark mode"]'); | ||
await sleep(300); | ||
const results = await new AxePuppeteer(page).analyze(); | ||
expect(results.violations).toHaveLength(0); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
rootDir: './', | ||
preset: 'jest-puppeteer', | ||
testMatch: ['<rootDir>/*.test.js'] | ||
}; |
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,27 +1,7 @@ | ||
module.exports = { | ||
preset: './preset.js', | ||
rootDir: './', | ||
roots: ['<rootDir>/src', '<rootDir>/tasks'], | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.(ts|tsx|js|mjs)$': [ | ||
'babel-jest', | ||
{ | ||
presets: ['next/babel'] | ||
} | ||
] | ||
}, | ||
testPathIgnorePatterns: ['capi', '.next', 'client'], | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
moduleNameMapper: { | ||
'\\.(css|less|scss)$': '<rootDir>/src/__mocks__/styleMock.js', | ||
'@docsearch/css(.*)': '<rootDir>/src/__mocks__/styleMock.js', | ||
'@/components/(.*)': '<rootDir>/src/components/$1', | ||
'@/constants/(.*)': '<rootDir>/src/constants/$1', | ||
'@/utils/(.*)': '<rootDir>/src/utils/$1', | ||
'@/data/(.*)': '<rootDir>/src/data/$1', | ||
'@/directory/(.*)': '<rootDir>/src/directory/$1', | ||
'@/themes/(.*)': '<rootDir>/src/themes/$1' | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!variables/.*)'] | ||
projects: [ | ||
'<rootDir>/jest.unit.config.js', | ||
'<rootDir>/e2e/jest.e2e.config.js' | ||
] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
preset: './preset.js', | ||
rootDir: './', | ||
roots: ['<rootDir>/src', '<rootDir>/tasks'], | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.(ts|tsx|js|mjs)$': [ | ||
'babel-jest', | ||
{ | ||
presets: ['next/babel'] | ||
} | ||
] | ||
}, | ||
testPathIgnorePatterns: ['capi', '.next', 'client'], | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
moduleNameMapper: { | ||
'\\.(css|less|scss)$': '<rootDir>/src/__mocks__/styleMock.js', | ||
'@docsearch/css(.*)': '<rootDir>/src/__mocks__/styleMock.js', | ||
'@/components/(.*)': '<rootDir>/src/components/$1', | ||
'@/constants/(.*)': '<rootDir>/src/constants/$1', | ||
'@/utils/(.*)': '<rootDir>/src/utils/$1', | ||
'@/data/(.*)': '<rootDir>/src/data/$1', | ||
'@/directory/(.*)': '<rootDir>/src/directory/$1', | ||
'@/themes/(.*)': '<rootDir>/src/themes/$1' | ||
} | ||
}; |
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
Oops, something went wrong.