Skip to content

Instantly share code, notes, and snippets.

@mrflip
Created October 25, 2022 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrflip/edfff1339eb9a2ff3c96be0cdb5a9e69 to your computer and use it in GitHub Desktop.
Save mrflip/edfff1339eb9a2ff3c96be0cdb5a9e69 to your computer and use it in GitHub Desktop.
Make chai and jest be friends
// make directories for 'tests' and 'src'.
// put this file in the base of your project;
// put all of your code in ./src and all of your tests in ./tests.
module.exports = {
roots: [
'tests',
'src',
],
// The glob patterns Jest uses to detect test files -- put all your files in
testMatch: ["**/*.test.[tj]s?(x)"],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ['./tests/setupFilesAfterEnv.js'],
}
// put this in tests/setupFilesAfterEnv.js
import Chai from 'chai'
import ChaiAsPromised from 'chai-as-promised'
Chai.use(ChaiAsPromised) // must be last
global.expect = Chai.expect
Error.stackTraceLimit = 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment