Skip to content

Instantly share code, notes, and snippets.

@thebuilder thebuilder/jest.config.js
Last active Jun 8, 2018

Embed
What would you like to do?
Use Jest Projects to run both JSDom and Node tests in the same project
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)',
]
},
],
};
@thebuilder

This comment has been minimized.

Copy link
Owner Author

commented Jun 8, 2018

Use Jest Projects to run tests targeting both JSDom and Node. Perfect if you are are doing SSR and want to validate your code, while also testing code running in the browser.

These matches looks for *.test.js and *test.node.js, but feel free to configure these to match your project. Maybe you want to use Node for all tests under server/?

Just use jest like you normally to run the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.