Transform nanoid module in Jest tests

This commit is contained in:
Koen Vlaswinkel
2023-10-03 10:48:08 +02:00
parent 99dabb0779
commit f678f49bc9
2 changed files with 24 additions and 27 deletions

View File

@@ -180,10 +180,10 @@ const config: Config = {
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// 'transformIgnorePatterns': [
// // These use ES modules, so need to be transformed
// 'node_modules/(?!(?:@vscode/webview-ui-toolkit|@microsoft/.+|exenv-es6)/.*)'
// ],
transformIgnorePatterns: [
// These use ES modules, so need to be transformed
"node_modules/(?!(?:@vscode/webview-ui-toolkit|@microsoft/.+|exenv-es6|nanoid)/.*)",
],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

View File

@@ -1,4 +1,5 @@
import type { Config } from "jest";
import { resolve } from "path";
/*
* For a detailed explanation regarding each configuration property and type check, visit:
@@ -163,31 +164,27 @@ const config: Config = {
// testRunner: "jest-circus/runner",
// A map from regular expressions to paths to transformers
// transform: {
// '^.+\\.tsx?$': [
// 'ts-jest',
// {
// tsconfig: 'src/view/tsconfig.spec.json',
// },
// ],
// 'node_modules': [
// 'babel-jest',
// {
// presets: [
// '@babel/preset-env'
// ],
// plugins: [
// '@babel/plugin-transform-modules-commonjs',
// ]
// }
// ]
// },
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: resolve(__dirname, "../tsconfig.json"),
},
],
node_modules: [
"babel-jest",
{
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-transform-modules-commonjs"],
},
],
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// 'transformIgnorePatterns': [
// // These use ES modules, so need to be transformed
// 'node_modules/(?!(?:@vscode/webview-ui-toolkit|@microsoft/.+|exenv-es6)/.*)'
// ],
transformIgnorePatterns: [
// These use ES modules, so need to be transformed
"node_modules/(?!(?:@vscode/webview-ui-toolkit|@microsoft/.+|exenv-es6|nanoid)/.*)",
],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,