I'm currently in the process of setting up a unit testing framework using typescript, karma, and mocha. I am utilizing karma-typescript for transpiling and es6-transform-karma-typescript to convert es6 code to browser-compatible es5 code. However, my progress seems to be halted at this particular line:
16 08 2021 19:34:35.898:INFO [compiler.karma-typescript]: Compiled 64 files in 6103 ms.
16 08 2021 19:34:36.422:DEBUG [bundler.karma-typescript]: Project has 247 import/require statements, code will be bundled
**16 08 2021 19:34:36.500:DEBUG [es6-transform.karma-typescript]: Transforming /Users/test/sourcecode/test-web-ui/src/app/Memory.js**
Below are the settings from my tsconfig.json file and karma.conf file.
karma.conf:
const {dirname, join, resolve} = require("path");
module.exports = (config) => {
config.set({
plugins: ['karma-chrome-launcher', 'karma-mocha', 'karma-typescript', 'karma-webpack', 'webpack','karma-mocha-reporter'],
frameworks: ['mocha', 'karma-typescript'],
preprocessors: {
"**/*.ts": ["karma-typescript"],
"**/*.tsx": ["karma-typescript"] // *.tsx for React Jsx
},
logLevel: config.LOG_DEBUG,
browsers: ['Chrome'],
singleRun: true,
autoWatch: false,
color:true,
reporters: ["mocha", "karma-typescript"],
files: [{ pattern: "src/**/*.ts" }, {pattern: "src/**/*.tsx" }],
karmaTypescriptConfig: {
stopOnFailure: true,
bundlerOptions: {
acornOptions: {
ecmaVersion: 8,
},
transforms: [
require("karma-typescript-es6-transform")({
presets: [require("@babel/preset-env")]
})
]
},
compilerOptions: {
target: "ES2015",
lib: ["ESNext", "dom"],
module: "CommonJS",
incremental: false
},
tsconfig: "testing.tsconfig.json"
}
});
}
tsconfig.json:
{
"compilerOptions": {
"target": "ES2017",
"module": "CommonJS",
"incremental": true,
"noUnusedParameters": false,
"sourceMap": true,
"jsx": "react",
"strict": true,
"esModuleInterop": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["src/**/*.ts","src/**/*.tsx"],
"exclude": ["node_modules"]
}
To run the tests, I have included the following command in my package.json file:
"test": "karma start karma.conf.js --log-level=DEBUG",
If anyone could assist in identifying the issue, that would be greatly appreciated.