Presets
Set a preset with Jest’s preset key:
export default { preset: '@repobuddy/jest/presets/ts-esm',}Each preset is exported as @repobuddy/jest/presets/<name> and as @repobuddy/jest/presets/<name>/jest-preset, in
ESM and CommonJS builds. The same objects are on the presets namespace of the main
entry.
| Preset | Language | Module format | Environment | Transform |
|---|---|---|---|---|
ts |
TypeScript | from package.json type |
node | as ts-esm or ts-cjs |
ts-esm |
TypeScript | ESM | node | @swc/jest |
ts-cjs |
TypeScript | CommonJS | node | ts-jest, jest-esm-transformer-2 |
js-esm |
JavaScript | ESM | node | Jest’s default |
js-cjs |
JavaScript | CommonJS | node | jest-esm-transformer-2 |
jsdom-ts |
TypeScript | from package.json type |
jsdom | as jsdom-ts-esm or jsdom-ts-cjs |
jsdom-ts-esm |
TypeScript | ESM | jsdom | @swc/jest |
jsdom-ts-cjs |
TypeScript | CommonJS | jsdom | ts-jest, jest-esm-transformer-2 |
watch |
any | any | any | none, watch plugins only |
-watch variants
Section titled “-watch variants”Each preset above except watch has a -watch variant. The variant is the base preset plus the watchPlugins of the
watch preset, and nothing else.
| Base | Variant |
|---|---|
ts |
ts-watch |
ts-esm |
ts-esm-watch |
ts-cjs |
ts-cjs-watch |
js-esm |
js-esm-watch |
js-cjs |
js-cjs-watch |
jsdom-ts |
jsdom-ts-watch |
jsdom-ts-esm |
jsdom-ts-esm-watch |
jsdom-ts-cjs |
jsdom-ts-cjs-watch |
What every preset except watch sets
Section titled “What every preset except watch sets”rootsandcollectCoverageFromfor one source folder. Seeconfigs.configSource().testEnvironmentand the test file patterns. See test file names.- The transform settings for its language and module format.
How your config combines with a preset
Section titled “How your config combines with a preset”Jest applies these rules (from jest-config 30):
- Keys in your config replace the preset’s keys.
moduleNameMapperandtransformmerge. Your patterns come first, then the preset’s patterns that you did not repeat. Jest uses the firsttransformpattern that matches a file.setupFilesandsetupFilesAfterEnvconcatenate: the preset’s entries, then yours.
See customize a preset.