test: use swc as the jest transformer

This commit is contained in:
Amin Yahyaabadi 2023-07-24 13:20:39 -07:00
parent 9fabf05a6b
commit 0b79280662
3 changed files with 48 additions and 16 deletions

View File

@ -1,23 +1,15 @@
import type { JestConfigWithTsJest } from "ts-jest"
import type { Config } from "jest"
const jestConfig: JestConfigWithTsJest = {
const jestConfig: Config = {
testMatch: ["**/*.test.ts"],
testEnvironment: "node",
// transform configurations
preset: "ts-jest/presets/js-with-ts-esm",
extensionsToTreatAsEsm: [".ts"],
extensionsToTreatAsEsm: [".ts", ".tsx", ".js", ".jsx"],
transformIgnorePatterns: [], // transform node_modules
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
importHelpers: true,
useESM: true,
},
],
"^.+\\.(t|j)sx?$": "@swc/jest",
},
// coverage
collectCoverageFrom: ["src/**/*.{ts,tsx}"],
collectCoverageFrom: ["src/**/*.{ts,tsx,js,jsx}"],
coveragePathIgnorePatterns: ["assets", ".css.d.ts"],
verbose: true,
detectOpenHandles: true,

View File

@ -76,6 +76,7 @@
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@babel/cli": "^7.22.9",
"@swc/jest": "^0.2.27",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^8.44.0",
"@types/jest": "^29.5.3",

View File

@ -26,6 +26,9 @@ importers:
'@babel/cli':
specifier: ^7.22.9
version: 7.22.9(@babel/core@7.22.9)
'@swc/jest':
specifier: ^0.2.27
version: 0.2.27(@swc/core@1.3.70)
'@types/cross-spawn':
specifier: ^6.0.2
version: 6.0.2
@ -175,7 +178,7 @@ importers:
version: 29.1.1(@babel/core@7.22.9)(jest@29.6.1)(typescript@5.1.6)
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/node@20.4.4)(typescript@5.1.6)
version: 10.9.1(@swc/core@1.3.70)(@types/node@20.4.4)(typescript@5.1.6)
ts-readme:
specifier: ^1.1.3
version: 1.1.3(typescript@5.1.6)
@ -1248,6 +1251,13 @@ packages:
- ts-node
dev: true
/@jest/create-cache-key-function@27.5.1:
resolution: {integrity: sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@jest/types': 27.5.1
dev: true
/@jest/environment@29.6.1:
resolution: {integrity: sha512-RMMXx4ws+Gbvw3DfLSuo2cfQlK7IwGbpuEWXCqyYDcqYTI+9Ju3a5hDnXaxjNsa6uKh9PQF2v+qg+RLe63tz5A==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@ -1395,6 +1405,17 @@ packages:
- supports-color
dev: true
/@jest/types@27.5.1:
resolution: {integrity: sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@types/istanbul-lib-coverage': 2.0.4
'@types/istanbul-reports': 3.0.1
'@types/node': 20.4.4
'@types/yargs': 16.0.5
chalk: 4.1.2
dev: true
/@jest/types@29.6.1:
resolution: {integrity: sha512-tPKQNMPuXgvdOn2/Lg9HNfUvjYVGolt04Hp03f5hAk878uwOLikN+JzeLY0HcVgKgFl9Hs3EIqpu3WX27XNhnw==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@ -2657,6 +2678,17 @@ packages:
tslib: 2.6.0
dev: true
/@swc/jest@0.2.27(@swc/core@1.3.70):
resolution: {integrity: sha512-Xt8EJ6Wy0NYVL8KDPcDMsuUSzyV2UAByamyy28x2iDZCJw2eVz3acedCGBYxxlPR/DNr6QbA35OSymuXhC9QVA==}
engines: {npm: '>= 7.0.0'}
peerDependencies:
'@swc/core': '*'
dependencies:
'@jest/create-cache-key-function': 27.5.1
'@swc/core': 1.3.70
jsonc-parser: 3.2.0
dev: true
/@szmarczak/http-timer@1.1.2:
resolution: {integrity: sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==}
engines: {node: '>=6'}
@ -2917,6 +2949,12 @@ packages:
resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==}
dev: true
/@types/yargs@16.0.5:
resolution: {integrity: sha512-AxO/ADJOBFJScHbWhq2xAhlWP24rY4aCEG/NFaMvbT3X2MgRsLjhjQwsn0Zi5zn0LG9jUhCCZMeX9Dkuw6k+vQ==}
dependencies:
'@types/yargs-parser': 21.0.0
dev: true
/@types/yargs@17.0.24:
resolution: {integrity: sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==}
dependencies:
@ -6951,7 +6989,7 @@ packages:
pretty-format: 29.6.1
slash: 3.0.0
strip-json-comments: 3.1.1
ts-node: 10.9.1(@types/node@20.4.4)(typescript@5.1.6)
ts-node: 10.9.1(@swc/core@1.3.70)(@types/node@20.4.4)(typescript@5.1.6)
transitivePeerDependencies:
- supports-color
dev: true
@ -10256,7 +10294,7 @@ packages:
yargs-parser: 21.1.1
dev: true
/ts-node@10.9.1(@types/node@20.4.4)(typescript@5.1.6):
/ts-node@10.9.1(@swc/core@1.3.70)(@types/node@20.4.4)(typescript@5.1.6):
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
@ -10271,6 +10309,7 @@ packages:
optional: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@swc/core': 1.3.70
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3