jsdom-ts-esm
jsdom-ts-esm runs TypeScript tests as native ES modules in the jsdom environment, transformed by @swc/jest.
export default { preset: '@repobuddy/jest/presets/jsdom-ts-esm',}NODE_OPTIONS=--experimental-vm-modules jestOptions
Section titled “Options”None. A preset takes no options.
Effective config
Section titled “Effective config”Printed from the built preset, in a directory that has a src folder:
{ extensionsToTreatAsEsm: ['.ts', '.mts', '.tsx'], moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { '^.+\\.(js|jsx|cjs|mjs|ts|tsx|cts|mts)$': '@swc/jest', }, collectCoverageFrom: [ '<rootDir>/src/**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}', '!<rootDir>/src/**/*.stories.*', ], roots: ['<rootDir>/src'], testEnvironment: 'jsdom', testMatch: [ '**/?*\\.(spec|test|unit|accept|integrate|learning|system|perf|stress)?(.jsdom).(js|jsx|cjs|mjs|ts|tsx|cts|mts)', ],}It is built from configs.tsEsm,
configs.configSource(), and
configs.jsdom.
Packages it needs
Section titled “Packages it needs”extract.extractPackages() on the preset returns:
['@swc/jest', 'jest-environment-jsdom']@repobuddy/jest does not declare jest-environment-jsdom. Install it yourself, along with @swc/jest and @swc/core.
Behavior
Section titled “Behavior”- Same transform and
.jsimport mapping asts-esm. - Uses
testMatchinstead oftestRegex. It runs<name>.<id>.<ext>and<name>.<id>.jsdom.<ext>. Node-only names such asa.spec.node.tsdo not run. See test file names. - Sets no
coveragePathIgnorePatterns. Jest skips test files from coverage on its own.
jsdom-ts-esm-watch variant
Section titled “jsdom-ts-esm-watch variant”@repobuddy/jest/presets/jsdom-ts-esm-watch is jsdom-ts-esm plus the watch plugins of the
watch preset.
Examples
Section titled “Examples”The jsdom-ts fixture in this repository:
export default { preset: '@repobuddy/jest/presets/jsdom-ts-esm-watch',}