2020-09-27 15:10:11 +03:00
|
|
|
// https://jestjs.io/docs/en/configuration.html
|
|
|
|
|
|
|
|
const isBrowser = process.env.BROWSER
|
|
|
|
const isActions = Boolean(process.env.GITHUB_ACTIONS)
|
2021-02-01 19:59:33 +03:00
|
|
|
const testTranslation = Boolean(process.env.TEST_TRANSLATION)
|
|
|
|
|
2021-03-26 22:21:45 +03:00
|
|
|
let reporters = ['default']
|
2021-02-01 19:59:33 +03:00
|
|
|
|
|
|
|
if (testTranslation) {
|
|
|
|
// only use custom reporter if we are linting translations
|
2021-03-26 22:21:45 +03:00
|
|
|
reporters = ['<rootDir>/tests/helpers/lint-translation-reporter.js']
|
2021-02-01 19:59:33 +03:00
|
|
|
} else if (isActions) {
|
|
|
|
reporters.push('jest-github-actions-reporter')
|
|
|
|
}
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
coverageThreshold: {
|
|
|
|
global: {
|
|
|
|
branches: 95,
|
|
|
|
functions: 95,
|
|
|
|
lines: 95,
|
2021-07-15 00:35:01 +03:00
|
|
|
statements: -5,
|
|
|
|
},
|
2020-09-27 15:10:11 +03:00
|
|
|
},
|
2021-07-15 00:35:01 +03:00
|
|
|
preset: isBrowser ? 'jest-puppeteer' : undefined,
|
2022-02-24 03:30:14 +03:00
|
|
|
moduleNameMapper: {
|
|
|
|
// fix for "Unexpected token 'export'" error when running jest
|
|
|
|
'@primer/behaviors': '<rootDir>/node_modules/@primer/behaviors/dist/cjs/index.js',
|
|
|
|
},
|
2021-02-01 19:59:33 +03:00
|
|
|
reporters,
|
2021-07-15 00:35:01 +03:00
|
|
|
modulePathIgnorePatterns: ['assets/'],
|
2022-02-25 19:49:27 +03:00
|
|
|
setupFilesAfterEnv: ['./jest.setup.js', '@alex_neo/jest-expect-message'],
|
2021-07-15 00:35:01 +03:00
|
|
|
...(isBrowser ? {} : { testEnvironment: 'node' }),
|
2020-09-27 15:10:11 +03:00
|
|
|
testPathIgnorePatterns: [
|
|
|
|
'node_modules/',
|
|
|
|
'vendor/',
|
2021-02-09 19:52:28 +03:00
|
|
|
'tests/fixtures/',
|
2020-11-24 23:41:50 +03:00
|
|
|
'tests/helpers/',
|
2021-02-09 19:52:28 +03:00
|
|
|
'tests/javascripts/',
|
2021-07-15 00:35:01 +03:00
|
|
|
...(isBrowser ? [] : ['tests/browser/browser.js']),
|
2020-09-27 15:10:11 +03:00
|
|
|
],
|
2021-07-15 00:35:01 +03:00
|
|
|
testMatch: ['**/tests/**/*.js'],
|
|
|
|
testLocationInResults: isActions,
|
2022-03-19 00:46:07 +03:00
|
|
|
globalSetup: './script/start-server-for-jest.mjs',
|
|
|
|
globalTeardown: './script/kill-server-for-jest.mjs',
|
2020-09-27 15:10:11 +03:00
|
|
|
}
|