Karma test task fails after grunt-ts compiles typescript in js

I am currently converting an old Angular 1 project from ES5 to TS. We take the approach of renaming all obsolete files to typescript, fixing compilation errors, and writing new Angular 1 components using typescript. We use grunt-ts to compile. After successful compilation, we clear all created JS files using the grunt task.

Task : the grunt-ts task also completes after starting the karma testing task. But for some reason, js files occur in the source folder after grunt-ts ends and the karma task begins. That is why the karma task fails because it cannot find js spec files. I can’t understand why the generated grunt-ts js files happen in the source directory a bit later.

Here is the tsconfig file

{   "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "amd",
    "target": "es5",
    "noImplicitAny": false,
    "checkJs": false,
    "allowJs": true,
    "inlineSourceMap": true,
    "inlineSources": true,
    "removeComments": false,
    "types" : ["jasmine"],
    "lib": ["es2017", "dom"]   },   "include": [
     "src/**/*.ts"   ],   "exclude": [
     "node_modules",
     "dist",
     ".npmcache",
     "coverage",
     "dist",
     "docs",
     "grunt-build",
     "lib",
     "./",
     "typings",
     "modules",
     "target",
     "test"   ]

}

Here are the grunt-ts assignments

grunt.initConfig({
    ts: {
        default: {
             // specifying tsconfig as a boolean will use the 'tsconfig.json' in same folder as Gruntfile.js
             tsconfig: true
        },
        comileSources: {
            src: ["src/sources/**/*.ts"],
            reference: 'referencesSources.ts',
            tsconfig: true,
            out:'target/sources/sources.js',

        },
        spec: {
            reference: 'referencesSpecs.ts',
            src: ["referencesSpecs.ts", "test/spec/sources/**/*.ts"],
            tsconfig: true
        } }
+4
source share

Source: https://habr.com/ru/post/1681054/


All Articles