0.2.37 • Published 21 days ago

@swc/jest v0.2.37

Weekly downloads
836
License
MIT
Repository
github
Last release
21 days ago

@swc/jest

SWC binding for Jest.

Installation

# if you use npm
npm i -D jest @swc/core @swc/jest
# if you use yarn
yarn add -D jest @swc/core @swc/jest

Usage

jest.config.js:

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': '@swc/jest',
  },
}

It will load the SWC configuration from .swcrc by default. You also can customize it:

const fs = require('fs')

const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8'))

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, /* custom configuration in Jest */ }],
  },
}

Q & A

Q: Jest uses CommonJS by default. But I want to use ESM.

A: Setup Jest following this Guide.

For JavaScript, edit package.json as follows:

{
  // ...
  "type": "module"
}

For TypeScript, edit jest.config.js as follows:

module.exports = {
  // ...
  extensionsToTreatAsEsm: ['.ts', '.tsx'],
}

Run test with --experimental-vm-modules:

cross-env NODE_OPTIONS=--experimental-vm-modules jest

# or
node --experimental-vm-modules ./node_modules/jest/bin/jest.js

Q: What ECMAScript target is set by jsc.target?

A: By default, the version supported by your Node runtime.

Node versionDefault jsc.target
12'es2018'
13'es2019'
14'es2020'
15'es2021'
16'es2021'
17'es2022'

You can customize this by setting an explicit version in jest.config.js:

module.exports = {
    transform: {
        "^.+\\.(t|j)sx?$": [
            "@swc/jest",
            {
                jsc: {
                    target: "es2021",
                },
            },
        ],
    },
}

License

MIT

@atmosfera/jest-config@infinitebrahmanuniverse/nolb-_swc@everything-registry/sub-chunk-886tdp_coretailwind-radix-colorsweb3-security-snaprockmantest-runner-with-snap-speed-exptest-runner-with-snap-speed-exp2visyn_scriptsvanify@developpeurdurable/nx-workspace-pluginmhymetacraftmodular-scriptsmongodb-safe-queryplugin-jestreact-scripts-dependencies-upgradedreact-app-rewired-swcsquakrunes-jstypescript-dev-loop@ainc/jest@amazeelabs/jest-preset@atls/config-jest@asyncapi/modelina@autosoft/jest-preset@aklesky/jest-config@backstage/cli@cartable/core@dfatwork-pkgs/backstage-cli@darcytech/jest-preset-darcytechwebpack-build-tooluniversal-scripts@fcsukltd/config@dustin-ruetz/devdeps@haojian-app/jest-preset@hutm/footing@elliemae/pui-cli@essex/jest-config@functionless/jest@infinum/jest@liveauctioneers/hammer-ui-testing-utils@langchain/langgraph-checkpoint-validation@lowdefy/jest-yaml-transform@m78/build-tools@m78/lib-build@matejlauko/jest-presets@marigold/jest-config@neodx/config@niieani/scaffold@equinor/opt-dev@faasjs/jest@metacraft/cli@mediaplatform/sportal365-tennis-sdk@jameslnewell/jest-preset@jameslnewell/jest-preset-node@jterrazz/package-typescript-test@nordicsemiconductor/pc-nrfconnect-shared@rafyamada/jest-default-config@s-ui/jest@stijnvanhulle/jest-builder@planjs/react-cli-service@packasso/jest@subash054/cli@sylo-digital/scripts@snout/jest-config@tarantool.io/tcm-jest-config@storybook/test-runner@rickzhou/react-test@code-style/jest-configs@d-leb/swc-jest@dev-spendesk/cli@powerfulyang/linteh-react-scripts-legacy@techor/jest@tksst/typescript-starter@webdesserts/app-scripts@volkovlabs/grafana-utils@venok/cli@versini/dev-dependencies-server@toptal/davinci-qa@tty-pt/scriptsbinance-local-exchangearui-scriptscraco-swccrontab-sentencechakra-12345codeaprocomponetos
0.2.37

21 days ago

0.2.36

10 months ago

0.2.34

10 months ago

0.2.33

10 months ago

0.2.32

10 months ago

0.2.31

10 months ago

0.2.30

10 months ago

0.2.27

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.26

2 years ago

0.2.25

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.7

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago