Tests broken after migrating from CLI 1.7.4 -> 6.x.x
Angular CLI: 6.0.5
Node: 8.11.2
OS: win32 x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.6.5 (cli-only)
@angular-devkit/build-angular 0.6.5
@angular-devkit/core 0.6.5 (cli-only)
@angular-devkit/schematics 0.6.5 (cli-only)
@angular/cli 6.0.5
@ngtools/webpack 6.0.5
@schematics/angular 0.6.5 (cli-only)
@schematics/update 0.6.5 (cli-only)
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3
"scripts": {
"build": "npm run build:dev",
"build:dev": "npm run clean:dist && ng build",
"build:prod": "npm run lint && npm run clean:dist && ng build --prod",
"clean": "npm cache verify && npm run rimraf -- node_modules doc coverage dist",
"clean:dist": "npm run rimraf -- dist",
"clean:install": "npm cache verify && npm install",
"e2e": "ng e2e",
"rimraf": "rimraf",
"lint": "ng lint",
"start": "node server/index.js",
"serve": "ng serve --hmr",
"qa": "npm run lint && npm run test",
"test": "ng test --code-coverage=true --source-map=true --watch=false",
"test:watch": "ng test --code-coverage=true --source-map=true",
"watch:dev": "npm run build:dev -- --watch",
"watch:prod": "npm run build:prod -- --watch"
},
"dependencies": {
"@angular/animations": "6.0.3",
"@angular/common": "6.0.3",
"@angular/compiler": "6.0.3",
"@angular/core": "6.0.3",
"@angular/forms": "6.0.3",
"@angular/http": "6.0.3",
"@angular/platform-browser": "6.0.3",
"@angular/platform-browser-dynamic": "6.0.3",
"@angular/router": "6.0.3",
"@angularclass/hmr": "2.1.3",
"@ngrx/effects": "6.0.1",
"@ngrx/store": "6.0.1",
"@ngrx/store-devtools": "6.0.1",
"busboy": "0.2.14",
"core-js": "2.5.6",
"express": "4.16.3",
"express-session": "1.15.6",
"file-saver": "1.3.8",
"font-awesome": "4.7.0",
"grant-express": "4.1.1",
"jsonwebtoken": "8.2.1",
"lodash": "4.17.10",
"lodash-decorators": "5.0.0",
"moment": "2.22.1",
"mydatepicker": "2.6.3",
"npm-run-script": "0.0.4",
"numeral": "2.0.6",
"primeng": "6.0.0-alpha.1",
"request": "2.87.0",
"rxjs": "6.2.0",
"rxjs-compat": "6.2.0",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.5",
"@angular/cli": "^6.0.5",
"@angular/compiler-cli": "6.0.3",
"@angular/language-service": "6.0.3",
"@types/jasmine": "2.8.7",
"@types/jasminewd2": "2.0.3",
"@types/node": "8.9.1",
"@types/numeral": "0.0.22",
"angular2-template-loader": "0.6.2",
"codelyzer": "4.3.0",
"jasmine-core": "2.8.0",
"jasmine-marbles": "0.3.1",
"jasmine-spec-reporter": "4.2.1",
"karma": "1.7.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.0",
"karma-jasmine": "1.1.2",
"karma-mocha-reporter": "2.2.5",
"protractor": "5.3.2",
"rimraf": "2.6.2",
"ts-node": "5.0.1",
"tslint": "5.10.0",
"typescript": "2.7.2",
"wallaby-webpack": "3.9.8"
}
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-mocha-reporter'),
require('karma-chrome-launcher'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
browserNoActivityTimeout: 20000,
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'clover'],
fixWebpackSourcePaths: true,
'report-config': {
html: { subdir: 'html' }
}
},
reporters: ['mocha', 'progress', 'coverage-istanbul'],
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['CustomChromeHeadless'],
singleRun: false,
customLaunchers: {
CustomChromeHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
});
};
25 05 2018 16:07:38.481:DEBUG [plugin]: Loading inlined plugin (defining framework:jasmine).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining reporter:mocha).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:ChromiumHeadless, launcher:Dartium, test).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining reporter:coverage-istanbul).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining framework:@angular-devkit/build-angular, reporter:@angular-devkit/build-angular--sourcemap-reporter, reporter:@angular-devkit/build-angular--event-reporter, middleware:@angular-devkit/build-angular--blocker, middleware:@angular-devkit/build-angular--fallback).
25 05 2018 16:07:38.491:DEBUG [plugin]: Loading inlined plugin (defining launcher:CustomChromeHeadless).
10% building modules 1/1 modules 0 active25 05 2018 16:07:38.784:DEBUG [web-server]: Instantiating middleware
25 05 2018 16:07:38.784:DEBUG [reporter]: Trying to load reporter: @angular-devkit/build-angular--sourcemap-reporter
25 05 2018 16:07:38.792:DEBUG [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--sourcemap-reporter (@angular-devkit/build-angular--sourcemap-reporter_color)
25 05 2018 16:07:38.794:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load reporter: @angular-devkit/build-angular--event-reporter
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--event-reporter (@angular-devkit/build-angular--event-reporter_color)
25 05 2018 16:07:38.794:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load reporter: mocha
25 05 2018 16:07:38.802:DEBUG [reporter]: Trying to load color-version of reporter: mocha (mocha_color)
25 05 2018 16:07:38.804:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.825:DEBUG [reporter]: Trying to load reporter: coverage-istanbul
25 05 2018 16:07:38.825:DEBUG [reporter]: Trying to load color-version of reporter: coverage-istanbul (coverage-istanbul_color)
25 05 2018 16:07:38.825:DEBUG [reporter]: Couldn't load color-version.
(node:30580) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
25 05 2018 16:08:00.485:DEBUG [karma]: List of files has changed, trying to execute
25 05 2018 16:08:00.485:WARN [karma]: No captured browser, open http://localhost:9876/
25 05 2018 16:08:00.495:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
25 05 2018 16:08:00.495:INFO [launcher]: Launching browser CustomChromeHeadless with unlimited concurrency
25 05 2018 16:08:00.505:INFO [launcher]: Starting browser ChromeHeadless
25 05 2018 16:08:00.505:DEBUG [temp-dir]: Creating temp dir at C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554
25 05 2018 16:08:00.513:DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications --no-sandbox http://localhost:9876/?id=46718554 --headless --disable-gpu --remote-debugging-port=9222 25 05 2018 16:08:33.330:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/client.html
25 05 2018 16:08:33.386:DEBUG [karma]: List of files has changed, trying to execute
25 05 2018 16:08:33.388:WARN [karma]: No captured browser, open http://localhost:9876/
25 05 2018 16:08:33.537:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/karma.js
25 05 2018 16:08:33.638:DEBUG [karma]: A browser has connected on socket aOSdGmZGd8SpT_HGAAAA
25 05 2018 16:08:33.883:INFO [HeadlessChrome 66.0.3359 (Windows 10.0.0)]: Connected on socket aOSdGmZGd8SpT_HGAAAA with id 46718554
25 05 2018 16:08:33.883:DEBUG [launcher]: ChromeHeadless (id 46718554) captured in 33.388 secs
25 05 2018 16:08:33.883:DEBUG [karma]: All browsers are ready, executing
25 05 2018 16:08:33.883:DEBUG [karma]: Captured 1 browsers
START:
25 05 2018 16:08:34.554:DEBUG [middleware:karma]: custom files C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-debug.html null
25 05 2018 16:08:34.555:DEBUG [middleware:karma]: Serving customContextFile C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html
25 05 2018 16:08:34.558:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=aOSdGmZGd8SpT_HGAAAA
25 05 2018 16:08:36.302:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/runtime.js /
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/runtime.js
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/polyfills.js /
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/polyfills.js
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js?f894bb45358bceea281c12011b12863c67d3942c /
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js?fcb459e84379f1ce8e91fe200d87463f3780ca1b /
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js
25 05 2018 16:08:37.064:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?73bc53d3671677e6a093fc74e4f9bcde57e5f7ad /
25 05 2018 16:08:37.064:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
25 05 2018 16:08:37.180:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js?6cf71867f538f40db053c1775b2c56a83696375c /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/scripts.js /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/scripts.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.js /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.js
25 05 2018 16:08:37.338:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/context.js
25 05 2018 16:08:37.342:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.js /
25 05 2018 16:08:37.342:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.js
25 05 2018 16:08:37.342:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js
25 05 2018 16:08:37.342:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js
HeadlessChrome 66.0.3359 (Windows 10.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
Finished in 0.004 secs / 0 secs @ 16:08:39 GMT+0700 (Tomsk Standard Time)
SUMMARY:
√ 0 tests completed
25 05 2018 16:08:39.143:DEBUG [reporter.coverage-istanbul]: Writing coverage reports: [ 'html', 'clover' ]
25 05 2018 16:09:11.637:DEBUG [launcher]: Disconnecting all browsers
25 05 2018 16:09:11.825:DEBUG [launcher]: Process ChromeHeadless exited with code 0
25 05 2018 16:09:11.835:DEBUG [temp-dir]: Cleaning temp dir C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554
25 05 2018 16:09:11.878:DEBUG [launcher]: Finished all browsers
I have the same problem, after upgrading. Creating a new project with ng new works fine however, but even copying the karma.conf.js, test.ts, angular.json, tsconf.spec.json and relevant parts of package.json from the working project into my upgraded project and even the app.component.spec.ts I still get same behaviour, Executed 0 of 0 ERROR, I really don't get what else could be affecting this!
Just one more thing I though about, since 6.0 my application does not compile in jit mode anymore, some kind of obscure circular dependency, it works fine in aot though, so that is what I intend to run, but the unit testing cannot be run in aot, correct? So might this be the problem. Not sure how much of the application is actually built for the unit testing, so I cannot say if it bootstraps or not.
What I tried to fix this problem:
Also one more thing: Wallaby.js can run tests correctly
Did some debugging, to se if I could understand something, but the only significant find I had was that a breakpoint in test.ts in my converted app is never reached, but in the ng newed app it is, so something is preventing test.ts from being called...
I found some things that can break tests this way, however I have not been able to get my specific app to work yet. It seems like though, this behavior is really not only one problem, it seems to be a specific kind of issue, where something goes wrong probably when doing some kind of bootstrapping, but ng test does not report that, so it is almost impossible to find out what the actual problem is.
So my guess is that when you get Executed 0 of 0 ERROR... it really means that the "testbench app" built by the ng test command, fails to bootstrap, however there is no log anywhere that says why, and the debug tools console is clean too.
However this is a simple way of reproducting this problem:
import "zone.js/dist/zone-patch-rxjs"; after the zone.js/dist/zone importnpm install rxjs-compatA bit curious also to if this problem is actually connected to rxjs-compat in some way.
Facing the same issue here. I've spent some time debugging but still have no idea about the source of the problem 😞.
Try to change the karma.conf basePath property. I had it with empty value and fixing it with / solved the problem for me.
This was failing:
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
.....
This works perfect for me:
config.set({
basePath: '/',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
.....
We have the same problem. No idea what's wrong no comment from angular-cli team here ... really strange
Can someone provide me a repro app where this happens?
@filipesilva see also https://github.com/angular/angular-cli/issues/10485. Im not able to reproduce with new ng project and ours is private to upload.
I found solution for my case:
Problem whas that we import something from rxjs-compat in polyfills.ts, steps to reproduce:
npm install -g @angular/[email protected]ng new cli-appnpm install --save rxjs-compatimport 'rxjs/add/observable/combineLatest';Steps to resolve:
same issue here,
ng test
10% building modules 1/1 modules 0 active(node:21481) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
07 06 2018 11:34:57.071:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
07 06 2018 11:34:57.072:INFO [launcher]: Launching browser Chrome with unlimited concurrency
07 06 2018 11:34:57.077:INFO [launcher]: Starting browser Chrome
07 06 2018 11:35:14.345:INFO [Chrome 66.0.3359 (Mac OS X 10.13.2)]: Connected on socket xiB3rSycTeIm1ojqAAAA with id 32977929
Chrome 66.0.3359 (Mac OS X 10.13.2): Executed 0 of 0 ERROR (0.012 secs / 0 secs)
Don't know how to solve this :(
here is my dependency info
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.0
Node: 9.8.0
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.6.0
@angular-devkit/build-optimizer 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@angular/cdk 6.0.1
@angular/pwa 0.6.0
@ngtools/webpack 6.0.0
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
the chrome will start up, but it auto closed after error occur
My project updated from Angular 5 -> Angular 6 when Angular 6 release,
"Test.ts , typing.spec.config , karma.config.js " are same with "ng new APP" files
@100cm could you also provide your package.json and polyfills.ts ?
please update to latest angular-cli version this bug was fixed with 6.0.8
On 7 June 2018 at 11:41, Andrey Chalkin notifications@github.com wrote:
@100cm https://github.com/100cm could you also provide your
package.json and polyfills.ts ?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/11011#issuecomment-395359013,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQ8j8oVlivFiMMZPyXIgRy8E2FPZbEvhks5t6PUsgaJpZM4UNoly
.
@L2jLiga
i have solved this problem by updating angular-cli to V6.0.8
@elvirdolic unfortunately it's still doesn't work for me as it work in CLI 1.7.4: if I add rxjs-compact imports into polyfills.ts.
Behaviour on CLI <= 1.7.4:
All tests executed sucessfully
Behaviour on CLI >= 6.0.0 & < 6.0.8
Executed 0 of 0 ERROR
Behaviour on CLI >= 6.0.8
All tests executed but tests which was written with RxJS 5 are fails.
For example this.userService.getOperationalEntities().flatMap is not a function
you don't need to add rxjs-compact into polyfills and use the latest version 6.0.8
This changes was made a long time ago and when I join to project we already have it in polyfills. After migration to Angular 6 we confronted with problem that tests aren't running.
Solution was that we moved this polyfills into separated file which we import in main.ts and test.ts both.
As I understand this imports was made because developers didn't want to duplicate they in each file which depends by this imports.
Our project is too large to migrate to RxJS 6 in one step and of course we don't need this in polyfills but after migration.
I'm using @angular/[email protected] and I haven't put anything other than the defaults in the polyfills.ts and I'm having this problem after upgrading.
@Nxt3 could you provide some more information?
Nobody can help you without it. I guess if you provide your package.json, karma.conf.js and test.ts we can find solution.
angular.json
"projects": {
"federation": {
"root": "apps/federation/",
"sourceRoot": "apps/federation/src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apps/federation",
"index": "apps/federation/src/index.html",
"main": "apps/federation/src/main.ts",
"polyfills": "apps/federation/src/polyfills.ts",
"tsConfig": "apps/federation/tsconfig.app.json",
"assets": [
"apps/federation/src/favicon.ico",
"apps/federation/src/assets",
{
"glob": "**/*",
"input": "libs/translate/locale",
"output": "/libs/locale"
}
],
"styles": ["apps/federation/src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/federation/src/environments/environment.ts",
"with": "apps/federation/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "federation:build"
},
"configurations": {
"production": {
"browserTarget": "federation:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "federation:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "apps/federation/src/test.ts",
"polyfills": "apps/federation/src/polyfills.ts",
"tsConfig": "apps/federation/tsconfig.app.json",
"karmaConfig": "apps/federation/karma.conf.js",
"styles": ["apps/federation/src/styles.scss"],
"scripts": [],
"assets": [
"./apps/federation/src/assets",
"./apps/federation/src/favicon.ico",
{
"glob": "**/*",
"input": "libs/translate/locale",
"output": "/libs/locale"
}
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/federation/tsconfig.app.json", "apps/federation/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
tsconfig.app.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/apps/federation",
"module": "es2015",
"types": []
},
"exclude": ["src/test.ts", "**/*.feature.ts", "**/*.spec.ts"],
"include": ["**/*.ts"]
}
tsconfig.spec.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/apps/federation",
"module": "commonjs",
"types": ["jasmine", "node"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
test.ts
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import 'zone.js/dist/zone-testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
karma.conf.js
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random: false
}
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
browserConsoleLogOptions: { level: 'disable', terminal: false },
logLevel: config.LOG_ERROR,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false
});
};
I actually get the error:
Module build failed: Error: /Users/ganttn/code/pi_ui/apps/federation/src/test.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
but, this works if in a newly generated app. I had it at one point that had the same error that was outlined above--but I'm so deep into this I have no idea what I've done to get here.
@Nxt3
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "apps/federation/src/test.ts",
"polyfills": "apps/federation/src/polyfills.ts",
"tsConfig": "apps/federation/tsconfig.app.json",
"karmaConfig": "apps/federation/karma.conf.js",
"styles": ["apps/federation/src/styles.scss"],
"scripts": [],
"assets": [
"./apps/federation/src/assets",
"./apps/federation/src/favicon.ico",
{
"glob": "**/*",
"input": "libs/translate/locale",
"output": "/libs/locale"
}
]
}
"tsConfig": "apps/federation/tsconfig.app.json", => "tsConfig": "apps/federation/tsconfig.spec.json",
@L2jLiga Noooooo I'm so embarrassed. Thanks for pointing out my mistake.
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Try to change the karma.conf
basePathproperty. I had it with empty value and fixing it with/solved the problem for me.This was failing:
This works perfect for me: