зеркало из https://github.com/github/docs.git
Fail on console.error in tests with failOnConsole (#25600)
* Install jest-fail-on-console * Setup and use failOnConsole * Add intentional 'unique key' error * Revert "Add intentional 'unique key' error" This reverts commit 5f75f069d80df36ce632421ae7ad26e98ac17ad3. * Comment about why use this package
This commit is contained in:
Родитель
156ec4b301
Коммит
8a7301d370
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
},
|
||||
reporters,
|
||||
modulePathIgnorePatterns: ['assets/'],
|
||||
setupFilesAfterEnv: ['@alex_neo/jest-expect-message'],
|
||||
setupFilesAfterEnv: ['./jest.setup.js', '@alex_neo/jest-expect-message'],
|
||||
...(isBrowser ? {} : { testEnvironment: 'node' }),
|
||||
testPathIgnorePatterns: [
|
||||
'node_modules/',
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import failOnConsole from 'jest-fail-on-console'
|
||||
|
||||
// Jest tests don't fail in some cases where we would see an error in DevTools
|
||||
// Console when running locally and we would also see the error in the test
|
||||
// output. This includes the React `Each child in a list should have a unique
|
||||
// "key" prop` error example.
|
||||
//
|
||||
// To catch this and fail tests in cases like this, we use `jest-fail-on-console`
|
||||
// to fail on calls to `console.error()`.
|
||||
failOnConsole({
|
||||
shouldFailOnWarn: false,
|
||||
})
|
|
@ -138,6 +138,7 @@
|
|||
"japanese-characters": "^1.1.0",
|
||||
"javascript-stringify": "^2.1.0",
|
||||
"jest": "^27.4.7",
|
||||
"jest-fail-on-console": "^2.2.3",
|
||||
"jest-github-actions-reporter": "^1.0.3",
|
||||
"jest-slow-test-reporter": "^1.0.0",
|
||||
"linkinator": "^3.0.3",
|
||||
|
@ -12195,6 +12196,31 @@
|
|||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-fail-on-console": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/jest-fail-on-console/-/jest-fail-on-console-2.2.3.tgz",
|
||||
"integrity": "sha512-fwSslH/Stq1NqN/z7PMYzUuHZxqimPCJOjj3D3RovpYCPXj/2WRiradhpVUm+tsSw4zW4MB9iJcXz6ggmw2nEg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-fail-on-console/node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-get-type": {
|
||||
"version": "27.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.4.0.tgz",
|
||||
|
@ -32059,6 +32085,27 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"jest-fail-on-console": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/jest-fail-on-console/-/jest-fail-on-console-2.2.3.tgz",
|
||||
"integrity": "sha512-fwSslH/Stq1NqN/z7PMYzUuHZxqimPCJOjj3D3RovpYCPXj/2WRiradhpVUm+tsSw4zW4MB9iJcXz6ggmw2nEg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^4.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"jest-get-type": {
|
||||
"version": "27.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.4.0.tgz",
|
||||
|
|
|
@ -140,6 +140,7 @@
|
|||
"japanese-characters": "^1.1.0",
|
||||
"javascript-stringify": "^2.1.0",
|
||||
"jest": "^27.4.7",
|
||||
"jest-fail-on-console": "^2.2.3",
|
||||
"jest-github-actions-reporter": "^1.0.3",
|
||||
"jest-slow-test-reporter": "^1.0.0",
|
||||
"linkinator": "^3.0.3",
|
||||
|
|
Загрузка…
Ссылка в новой задаче