Switched from ts-jest to @swc/jest
This commit is contained in:
parent
ca0547ed1a
commit
abbd60d7e2
@ -12,12 +12,14 @@
|
|||||||
"target": "es2022",
|
"target": "es2022",
|
||||||
"loose": true,
|
"loose": true,
|
||||||
"externalHelpers": false,
|
"externalHelpers": false,
|
||||||
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
|
||||||
"keepClassNames": true,
|
"keepClassNames": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@spt-aki/*": [
|
"@spt-aki/*": [
|
||||||
"src/*"
|
"src/*"
|
||||||
|
],
|
||||||
|
"@tests/*": [
|
||||||
|
"tests/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import type { JestConfigWithTsJest } from "ts-jest";
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { pathsToModuleNameMapper } from "ts-jest";
|
import type { Config } from "jest";
|
||||||
import { compilerOptions } from "./tsconfig.json";
|
import fs from "fs";
|
||||||
|
|
||||||
const config: JestConfigWithTsJest = {
|
const config: Config = {
|
||||||
preset: "ts-jest",
|
|
||||||
testEnvironment: "./tests/CustomEnvironment.ts",
|
testEnvironment: "./tests/CustomEnvironment.ts",
|
||||||
roots: [
|
roots: [
|
||||||
"./tests/"
|
"./tests/"
|
||||||
],
|
],
|
||||||
modulePaths: [ compilerOptions.baseUrl ],
|
transform: {
|
||||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths)
|
"^.+\\.ts$": [ "@swc/jest", JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, "utf-8")) ]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-env": "7.23.2",
|
"@babel/preset-env": "7.23.2",
|
||||||
"@babel/preset-typescript": "7.23.2",
|
"@babel/preset-typescript": "7.23.2",
|
||||||
|
"@jest/environment": "^29.7.0",
|
||||||
"@jest/globals": "29.7.0",
|
"@jest/globals": "29.7.0",
|
||||||
"@pnpm/exe": "8.9.0",
|
"@pnpm/exe": "8.9.0",
|
||||||
"@swc/cli": "0.1.62",
|
"@swc/cli": "0.1.62",
|
||||||
@ -63,12 +64,12 @@
|
|||||||
"gulp-execa": "5.0.1",
|
"gulp-execa": "5.0.1",
|
||||||
"gulp-rename": "2.0.0",
|
"gulp-rename": "2.0.0",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
|
"jest-environment-node": "^29.7.0",
|
||||||
"madge": "6.1.0",
|
"madge": "6.1.0",
|
||||||
"pkg": "5.8.1",
|
"pkg": "5.8.1",
|
||||||
"pkg-fetch": "3.5.2",
|
"pkg-fetch": "3.5.2",
|
||||||
"resedit": "2.0.0",
|
"resedit": "2.0.0",
|
||||||
"rome": "12.1.3",
|
"rome": "12.1.3",
|
||||||
"ts-jest": "29.1.1",
|
|
||||||
"ts-node-dev": "2.0.0",
|
"ts-node-dev": "2.0.0",
|
||||||
"tsconfig-paths": "4.2.0",
|
"tsconfig-paths": "4.2.0",
|
||||||
"typedoc": "0.25.2",
|
"typedoc": "0.25.2",
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
|
import { container } from "tsyringe";
|
||||||
|
|
||||||
import NodeEnvironment from "jest-environment-node";
|
import NodeEnvironment from "jest-environment-node";
|
||||||
import type {EnvironmentContext} from "@jest/environment";
|
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
|
||||||
import type {JestEnvironmentConfig} from "@jest/environment";
|
|
||||||
|
|
||||||
import { container } from "tsyringe";
|
|
||||||
import { Container } from "@spt-aki/di/Container";
|
import { Container } from "@spt-aki/di/Container";
|
||||||
|
|
||||||
class CustomEnvironment extends NodeEnvironment
|
export default class CustomEnvironment extends NodeEnvironment
|
||||||
{
|
{
|
||||||
constructor(config: JestEnvironmentConfig, context: EnvironmentContext)
|
constructor(config: JestEnvironmentConfig, context: EnvironmentContext)
|
||||||
{
|
{
|
||||||
@ -27,5 +26,3 @@ class CustomEnvironment extends NodeEnvironment
|
|||||||
await super.teardown();
|
await super.teardown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CustomEnvironment;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user