Skip to content

Presets

Set a preset with Jest’s preset key:

jest.config.mjs
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

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
  • roots and collectCoverageFrom for one source folder. See configs.configSource().
  • testEnvironment and the test file patterns. See test file names.
  • The transform settings for its language and module format.

Jest applies these rules (from jest-config 30):

  • Keys in your config replace the preset’s keys.
  • moduleNameMapper and transform merge. Your patterns come first, then the preset’s patterns that you did not repeat. Jest uses the first transform pattern that matches a file.
  • setupFiles and setupFilesAfterEnv concatenate: the preset’s entries, then yours.

See customize a preset.