jsdom-ts
jsdom-ts resolves to jsdom-ts-esm or
jsdom-ts-cjs, based on the type field of the nearest package.json.
export default { preset: '@repobuddy/jest/presets/jsdom-ts',}Options
Section titled “Options”None. A preset takes no options.
Effective config
Section titled “Effective config”When the preset loads, it reads the nearest package.json, starting from the directory Jest runs in:
package.json type |
Resolves to |
|---|---|
"module" |
the jsdom-ts-esm config |
anything else, or no package.json |
the jsdom-ts-cjs config |
Packages it needs
Section titled “Packages it needs”| Resolved to | Packages from extract.extractPackages() |
|---|---|
jsdom-ts-esm |
@swc/jest, jest-environment-jsdom |
jsdom-ts-cjs |
jest-environment-jsdom, jest-esm-transformer-2, ts-jest |
Behavior
Section titled “Behavior”- The choice happens once, when Jest loads the preset, and uses the working directory. See
ts. - An ESM result needs
NODE_OPTIONS=--experimental-vm-modules.
jsdom-ts-watch variant
Section titled “jsdom-ts-watch variant”@repobuddy/jest/presets/jsdom-ts-watch resolves the same way, to jsdom-ts-esm-watch or jsdom-ts-cjs-watch.
Examples
Section titled “Examples”The dual-ts-swc fixture ("type": "module") uses it in a second config file, with a mapper for uuid:
/** @type {import('jest').Config} */const config = { preset: '@repobuddy/jest/presets/jsdom-ts', detectOpenHandles: true, moduleNameMapper: { '^uuid$': require.resolve('uuid'), },}
module.exports = configRelated
Section titled “Related”ts: the same detection for Node.js.- DOM tests with jsdom