29.0.3 • Published 10 months ago

@repodog/jest-config v29.0.3

Weekly downloads
24
License
MIT
Repository
github
Last release
10 months ago

@repodog/jest-config

The Repodog Jest config.

npm version License: MIT

Install package and peer dependencies

# terminal
npm install @repodog/jest-config @jest/globals jest suppress-experimental-warnings --save-dev

Install optional peer dependencies

# terminal
npm install babel-jest --save-dev
# or
npm install @swc/jest --save-dev

Use package

With Babel

// package.json
{
  "scripts": {
    // esm
    "test": "node --require=suppress-experimental-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
    // or cjs
    "test": "MODULE_SYSTEM=cjs node node_modules/jest/bin/jest.js"
  }
}
// jest.config.cjs
const jestConfig = require('@repodog/jest-config');

module.exports = {
  ...jestConfig(),
};
// .vscode/launch.json
{
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Jest - current file",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "args": [
        "${relativeFile}"
      ],
      "env": {
        "DEBUG": "true",
        // esm
        "NODE_OPTIONS": "--experimental-vm-modules",
        // or cjs
        "MODULE_SYSTEM": "cjs"
      },
      "console": "integratedTerminal"
    }
  ]
}

With SWC

// package.json
{
  "scripts": {
    // esm
    "test": "COMPILER=swc node --require=suppress-experimental-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
    // or cjs
    "test": "COMPILER=swc MODULE_SYSTEM=cjs node node_modules/jest/bin/jest.js"
  }
}
// jest.config.cjs
const jestConfig = require('@repodog/jest-config');
const swcConfig = require('@repodog/swc-config');

module.exports = {
  ...jestConfig({ compilerOptions: swcConfig }),
};
// .vscode/launch.json
{
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Jest - current file",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "args": [
        "${relativeFile}"
      ],
      "env": {
        "DEBUG": "true",
        "COMPILER": "swc",
        // esm
        "NODE_OPTIONS": "--experimental-vm-modules",
        // or cjs
        "MODULE_SYSTEM": "cjs"
      },
      "console": "integratedTerminal"
    }
  ]
}

Environment variables

COMPILER = 'babel' || 'swc'

Uses either Babel or SWC to compile code for Jest. Default 'babel'.

MODULE_SYSTEM = 'esm' || 'cjs'

Sets the module sytem to either ESModules or commonjs. Default 'esm'.

DEBUG = 'true' || 'false'

Changes testMatch to cover all test files and disables the Jest timeout. These are useful to set when debugging a file in IDE. Default 'false'.

JS_ENV = 'web' || 'node'

When set to 'web', adds regexes to moduleNameMapper and transform to cater for .css and other file extensions Jest cannot resolve. Default 'node'.

29.0.3

10 months ago

29.0.2

11 months ago

29.0.1

12 months ago

1.2.6-alpha-12345.0

12 months ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.2.0-unstable.0

2 years ago

1.1.12

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.1

2 years ago

1.0.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0-alpha.0

2 years ago

1.0.1-alpha.0

2 years ago

1.0.2-alpha.0

2 years ago

1.0.0-alpha.0

3 years ago

0.3.32

6 years ago

0.3.31

6 years ago

0.3.30

6 years ago

0.3.29

6 years ago

0.3.28

6 years ago

0.3.27

6 years ago

0.3.26

6 years ago

0.3.25

6 years ago

0.3.24

6 years ago

0.3.23

6 years ago

0.3.22

6 years ago

0.3.21

6 years ago

0.3.20

6 years ago

0.3.18

6 years ago

0.3.17

6 years ago

0.3.16

6 years ago

0.3.15

6 years ago

0.3.12

6 years ago

0.3.10

6 years ago

0.2.26

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago