Switched from ts-jest to @swc/jest

This commit is contained in:
TheSparta 2023-10-26 21:01:38 +01:00
parent ca0547ed1a
commit abbd60d7e2
4 changed files with 15 additions and 15 deletions

View File

@ -12,12 +12,14 @@
"target": "es2022",
"loose": true,
"externalHelpers": false,
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
"keepClassNames": true,
"baseUrl": "./",
"paths": {
"@spt-aki/*": [
"src/*"
],
"@tests/*": [
"tests/*"
]
}
},

View File

@ -1,15 +1,15 @@
import type { JestConfigWithTsJest } from "ts-jest";
import { pathsToModuleNameMapper } from "ts-jest";
import { compilerOptions } from "./tsconfig.json";
/* eslint-disable @typescript-eslint/naming-convention */
import type { Config } from "jest";
import fs from "fs";
const config: JestConfigWithTsJest = {
preset: "ts-jest",
const config: Config = {
testEnvironment: "./tests/CustomEnvironment.ts",
roots: [
"./tests/"
],
modulePaths: [ compilerOptions.baseUrl ],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths)
transform: {
"^.+\\.ts$": [ "@swc/jest", JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, "utf-8")) ]
}
};
export default config;

View File

@ -44,6 +44,7 @@
"devDependencies": {
"@babel/preset-env": "7.23.2",
"@babel/preset-typescript": "7.23.2",
"@jest/environment": "^29.7.0",
"@jest/globals": "29.7.0",
"@pnpm/exe": "8.9.0",
"@swc/cli": "0.1.62",
@ -63,12 +64,12 @@
"gulp-execa": "5.0.1",
"gulp-rename": "2.0.0",
"jest": "29.7.0",
"jest-environment-node": "^29.7.0",
"madge": "6.1.0",
"pkg": "5.8.1",
"pkg-fetch": "3.5.2",
"resedit": "2.0.0",
"rome": "12.1.3",
"ts-jest": "29.1.1",
"ts-node-dev": "2.0.0",
"tsconfig-paths": "4.2.0",
"typedoc": "0.25.2",

View File

@ -1,13 +1,12 @@
import "reflect-metadata";
import { container } from "tsyringe";
import NodeEnvironment from "jest-environment-node";
import type {EnvironmentContext} from "@jest/environment";
import type {JestEnvironmentConfig} from "@jest/environment";
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
import { container } from "tsyringe";
import { Container } from "@spt-aki/di/Container";
class CustomEnvironment extends NodeEnvironment
export default class CustomEnvironment extends NodeEnvironment
{
constructor(config: JestEnvironmentConfig, context: EnvironmentContext)
{
@ -27,5 +26,3 @@ class CustomEnvironment extends NodeEnvironment
await super.teardown();
}
}
module.exports = CustomEnvironment;