Last active
October 29, 2022 02:42
-
-
Save thebuilder/15a084f74b1c6a1f163fc6254ad5a5ba to your computer and use it in GitHub Desktop.
Use Jest Projects to run both JSDom and Node tests in the same project
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
module.exports = { | |
projects: [ | |
{ | |
displayName: 'dom', | |
testEnvironment: 'jsdom', | |
snapshotSerializers: ['enzyme-to-json/serializer'], | |
testMatch: ['**/__tests__/**/*.test.js?(x)'] | |
}, | |
{ | |
displayName: 'node', | |
testEnvironment: 'node', | |
testMatch: [ | |
'**/__tests__/**/*.test.node.js?(x)', | |
] | |
}, | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This got me on the right track, thank you!
In my case I was missing another piece:
I have a unified project with both client/ and server/ code, each with their own package.json. I had to set
"type": "module"
in the package.json corresponding to the client (with jsdom environment) tests.Now my project root jest config works for all sub-projects.