Copyright (c) 2023–2024 Check Digit, LLC
Check Digit Jest presets and configuration.
$ npm i @checkdigit/jest-config --save-dev
Note that @checkdigit/jest-config
automatically brings in the correct versions of
jest
, ts-jest
and @jest/globals
via peerDependencies
. Do not install these packages separately.
@checkdigit/jest-config
is now ESM only.
It only supports testing with ESM modules,
i.e., you must have "type": "module"
in your package.json
file.
Note that the Node --experimental-vm-modules
flag is required for ESM modules. See the
Jest docs for more information.
The project .env
file is automatically loaded via process.loadEnvFile()
(available in Node.js 20.12 or later).
Note: this requires Node.js v20.11 or later.
{
// ...
"type": "module",
"scripts": {
"test": "NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false"
"test:coverage": "NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true"
}
// ...
"jest": {
"preset": "@checkdigit/jest-config"
}
}
MIT