1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/jest.config.js
Peter Bengtsson 4fcd3ae25f automatically start server for jest (#26206)
* reinstate

* start server manually

* routing tests too

* skip more

* sleep more and fail if not 200

* use e2etest for content/ too

* automatically start server for jest

* does this work?

* feedbacked

* rename things

* getting it to work

* add dev dependency

* install the right version

* don't need to start that

* fix package lock

* update readme about it

* feedbacked
2022-03-18 21:46:07 +00:00

47 lines
1.4 KiB
JavaScript

// https://jestjs.io/docs/en/configuration.html
const isBrowser = process.env.BROWSER
const isActions = Boolean(process.env.GITHUB_ACTIONS)
const testTranslation = Boolean(process.env.TEST_TRANSLATION)
let reporters = ['default']
if (testTranslation) {
// only use custom reporter if we are linting translations
reporters = ['<rootDir>/tests/helpers/lint-translation-reporter.js']
} else if (isActions) {
reporters.push('jest-github-actions-reporter')
}
module.exports = {
coverageThreshold: {
global: {
branches: 95,
functions: 95,
lines: 95,
statements: -5,
},
},
preset: isBrowser ? 'jest-puppeteer' : undefined,
moduleNameMapper: {
// fix for "Unexpected token 'export'" error when running jest
'@primer/behaviors': '<rootDir>/node_modules/@primer/behaviors/dist/cjs/index.js',
},
reporters,
modulePathIgnorePatterns: ['assets/'],
setupFilesAfterEnv: ['./jest.setup.js', '@alex_neo/jest-expect-message'],
...(isBrowser ? {} : { testEnvironment: 'node' }),
testPathIgnorePatterns: [
'node_modules/',
'vendor/',
'tests/fixtures/',
'tests/helpers/',
'tests/javascripts/',
...(isBrowser ? [] : ['tests/browser/browser.js']),
],
testMatch: ['**/tests/**/*.js'],
testLocationInResults: isActions,
globalSetup: './script/start-server-for-jest.mjs',
globalTeardown: './script/kill-server-for-jest.mjs',
}