@autosoft/jest-preset

1.0.5 • Public • Published

@autosoft/jest-preset

npm typescript

A base to easily run Jest with SWC.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter Follow


This package bundles Jest and SWC together, providing an fast and easy way to run tests.

It comes preconfigured to work with TypeScript and ESM.

Installation

yarn add --dev @autosoft/jest-preset
npm install --save-dev @autosoft/jest-preset
pnpm add --save-dev @autosoft/jest-preset

Usage

In your package.json file:

{
  "jest": {
    "preset": "@autosoft/jest-preset"
  }
}

Jest

Now to run jest, run yarn jest or npm run jest.

Jest Preset

All tests will need to be in the test directory and end with .test.ts. Additionally, coverage will be collected from all files in the source directory.

{
  "collectCoverage": true,
  "collectCoverageFrom": [
    "source/**/*.ts"
  ],
  "coverageProvider": "v8",
  "coverageReporters": [
    "text"
  ],
  "extensionsToTreatAsESM": [
    ".ts",
    ".tsx"
  ],
  "moduleNameMapper": {
    "^#(.*)": "$1",
    "^(\\.{1,2}/.*)\\.js$": "$1"
  },
  "testRegex": "test/(.*).test.ts$",
  "transform": {
    "^.+\\.tsx?$": [
      "@swc/jest", {
        "jsc": {
          "target": "es2019"
        }
      }
    ]
  }
}

Dependenciesdependencies

  • @swc/core: Super-fast alternative for babel
  • @swc/jest: swc integration for jest
  • jest: Delightful JavaScript Testing.

Dev Dependencies


License license

MIT - The MIT License

Package Sidebar

Install

npm i @autosoft/jest-preset

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

4.48 kB

Total Files

5

Last publish

Collaborators

  • bconnorwhite