Created
October 25, 2022 20:08
-
-
Save mrflip/edfff1339eb9a2ff3c96be0cdb5a9e69 to your computer and use it in GitHub Desktop.
Make chai and jest be friends
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
// 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'], | |
} |
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
// 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