0
i’m trying to use ts-jest in a Vue project to Transform some ". ts" files in "js" so jest can test them. My problem is: typescript Compiler Give me this error: _className.default is not a constructor
when trying to mount a Component for testing.
I have two files. In one of them I export a class like this:
class myClass {
//code
}
export default myClass;
The other file has:
import myClass from "path";
class anotherClass {
constructor() {
const foo = new myClass();
}
}
My .tsconfig
file:
{
"compilerOptions": {
"target": "ES2019",
"module": "CommonJS",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"resolveJsonModule": true,
"baseUrl": ".",
"types": ["webpack-env"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
"src/main.js",
"src/acl.js"
],
"exclude": ["node_modules"]
}
My jest config file:
module.exports = {
moduleFileExtensions: ["js", "json", "ts", "vue"],
transform: {
".*\\.(vue)$": "vue-jest",
".*\\.(ts)$": "ts-jest",
".*\\.(js)$": "babel-jest",
},
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
"\\.(scss|sass|css)$": "identity-obj-proxy",
},
coveragePathIgnorePatterns: [
"/node_modules/"
],
};
I can’t figure out what is happening.
Welcome(a) to the stack overflow in English. If you visit the Tour of the platform, you will find that the default language is the
PORTUGUÊS
. Welcome to the stack overflow in English. If you visit the Tour of the Platform, you will find that the default language isPORTUGUESE
.– Solkarped