Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Last active January 5, 2021 08:11
Show Gist options
  • Save mr-pascal/0d0d4ce294bf235bc1562f138b130e87 to your computer and use it in GitHub Desktop.
Save mr-pascal/0d0d4ce294bf235bc1562f138b130e87 to your computer and use it in GitHub Desktop.
// jest.config.js
module.exports = {
/**
* 1.
* Add some TypeScript specific Jest configuration (not needed if you use plain JS)
*/
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
/**
* 2.
* Add the preset @shelf/jest-mongodb to tell Jest that it should use the npm module
* we downloaded to apply some predefined settings for using the in-memory MongoDB
*/
preset: '@shelf/jest-mongodb',
/**
* 3.
* Define that the ./jest.setup.ts file should be run after the Jest environment was set up.
* This setup file will contain the ramp up/down of the in-memory MongoDB
*/
setupFilesAfterEnv: [
'./jest.setup.ts',
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment