@repodog/jest-config

1.2.5 • Public • Published

@repodog/jest-config

The Repodog Jest config.

npm version License: MIT

Install package

# terminal
npm install @repodog/jest-config --save-dev

Install dependencies

# terminal
npm install @jest/globals identity-obj-proxy jest suppress-experimental-warnings --save-dev

Install optional dependencies

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

Use package

// package.json
{
  "scripts": {
    "test": "node --require=suppress-experimental-warnings --experimental-vm-modules node_modules/jest/bin/jest.js"
  }
}

With Babel

// jest.config.cjs
const jestConfig = require('@repodog/jest-config');

module.exports = {
  ...jestConfig(),
};

With SWC

// 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",
        "NODE_OPTIONS": "--experimental-vm-modules"
      },
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
  ]
}

Environment variables

COMPILER = 'babel' || 'swc'

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

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'.

Readme

Keywords

none

Package Sidebar

Install

npm i @repodog/jest-config

Weekly Downloads

24

Version

1.2.5

License

MIT

Unpacked Size

7.12 kB

Total Files

7

Last publish

Collaborators

  • dylanaubrey