Minor refactoring to future proof against ts preset changes

This commit is contained in:
Dannon Baker
2024-08-05 15:18:28 -04:00
parent 705603820b
commit 679af5fb77
+17 -5
View File
@@ -1,6 +1,5 @@
const path = require("path");
const { defaults: tsjPreset } = require("ts-jest/presets");
const ts = require("typescript");
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
@@ -16,12 +15,25 @@ const modulesToTransform = [
"openapi-typescript-fetch",
].join("|");
const tsjPresetTransform = tsjPreset.transform;
// Override verbatimModuleSyntax to false to allow jest to transform the module syntax like it wants.
// This is necessary to allow jest to transform the module syntax to commonjs, which is necessary for
// jest to work properly. I think.
tsjPresetTransform[0].tsconfig.verbatimModuleSyntax = false;
const configOverride = {
"^.+.tsx?$": [
"ts-jest",
{
tsconfig: {
verbatimModuleSyntax: false,
},
},
],
};
const mergedTSJTransform = {
...tsjPreset.transform,
...configOverride,
};
module.exports = {
preset: "ts-jest",
@@ -56,7 +68,7 @@ module.exports = {
"^.*\\.(vue)$": "@vue/vue2-jest",
"^.+\\.ya?ml$": "<rootDir>/tests/jest/yaml-jest.js",
"^.+\\.txt$": "<rootDir>/tests/jest/jest-raw-loader.js",
...tsjPresetTransform,
...mergedTSJTransform,
},
transformIgnorePatterns: [`/node_modules/(?!${modulesToTransform})`],
};