1
votes

I would like to know if it's possible change the path test to another folder, for example:

test/jest/**/*.spec.ts
test/karma/**/*.spec.ts

This is what I'm trying, but without success

.angular-cli.json

"test": {
  "karma": {
    "config": "./karma.conf.js"
  },
  "codeCoverage": {
    "exclude": [
      "**/test/jest/*.spec.ts"
    ]
  }
},

karma.conf.js

exclude: [
  "**/test/jest/*.spec.ts"
]

src/test.ts

const context = require.context('./test/karma/', true, /\.spec\.ts$/);

src/tsconfig.spec.json

"exclude": [
  "**/test/jest/*.spec.ts"
]

When I run npm test, the karma tests doesn't work (which was working) and it still reading /test/jest/

ERROR in src/test/jest/services/cart.spec.ts(5,1): error TS2304: Cannot find name 'test'.

[karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
[launcher]: Launching browser Chrome with unlimited concurrency
[launcher]: Starting browser Chrome
[launcher]: Chrome have not captured in 60000 ms, killing.
[launcher]: Trying to start Chrome again (1/2).

I've already try reinstall my modules, but it still the same.

$ rm -rf node_modules
$ rm -f package-lock.json
$ npm cache clean --force
$ npm install

package.json

"@angular": "^5.2.9"
"@angular/cli": "^1.7.3"
"karma": "~2.0.0"
"karma-cli": "~1.0.1"
1

1 Answers

3
votes

The follow changes, did work.

karma.conf.js

exclude: [
  "**/test/jest/**/*.spec.ts"
]

tsconfig.spec.json

"exclude": [
  "**/test/jest/*"
]

.angular-cli.json

"test": {
  "karma": {
    "config": "./karma.conf.js"
  },
  "codeCoverage": {
    "exclude": [
      "**/test/jest/**/*.spec.ts"
    ]
  }
},