x
)- [ x ] bug report -> please search issues before submitting
- [ ] feature request
@angular/cli: 1.2.2
node: 6.11.0
os: win32 x64
@angular/animations: 4.3.3
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.2.2
@angular/compiler-cli: 4.3.3
@angular/language-service: 4.3.3
ng test
Simple runtime error example:
...
export class AppComponent implements OnInit {
title = 'app';
example: string;
ngOnInit() {
console.log(this.example.length);
}
}
Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/AppComponent_Host.ngfactory.js'.
at http://localhost:9876/_karma_webpack_/polyfills.bundle.js:5182:35
at XMLHttpRequest.proto.(anonymous function) [as send] (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:3767:20)
at Array.<anonymous> (node_modules/source-map-support/browser-source-map-support.js:107:176)
at node_modules/source-map-support/browser-source-map-support.js:101:106
at Array.<anonymous> (node_modules/source-map-support/browser-source-map-support.js:107:474)
at node_modules/source-map-support/browser-source-map-support.js:101:106
at a (node_modules/source-map-support/browser-source-map-support.js:101:312)
at b (node_modules/source-map-support/browser-source-map-support.js:104:348)
at node_modules/source-map-support/browser-source-map-support.js:105:245
at Array.map (native)
Display the actual error message with details about the error. Here's the output from 1.2.1.
@angular/cli: 1.2.1
node: 6.11.0
os: win32 x64
@angular/animations: 4.3.3
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.2.1
@angular/compiler-cli: 4.3.3
@angular/language-service: 4.3.3
Failed: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at AppComponent.webpackJsonp.../../../../../src/app/app.component.ts.AppComponent.ngOnInit (http://localhost:9876/_karma_webpack_/main.bundle.js:120:33)
at checkAndUpdateDirectiveInline (http://localhost:9876/_karma_webpack_/vendor.bundle.js:47071:19)
at checkAndUpdateNodeInline (http://localhost:9876/_karma_webpack_/vendor.bundle.js:48567:17)
at checkAndUpdateNode (http://localhost:9876/_karma_webpack_/vendor.bundle.js:48506:16)
at debugCheckAndUpdateNode (http://localhost:9876/_karma_webpack_/vendor.bundle.js:49367:59)
at debugCheckDirectivesFn (http://localhost:9876/_karma_webpack_/vendor.bundle.js:49308:13)
at Object.eval [as updateDirectives] (ng:///DynamicTestModule/AppComponent_Host.ngfactory.js:8:5)
at Object.debugUpdateDirectives [as updateDirectives] (http://localhost:9876/_karma_webpack_/vendor.bundle.js:49293:21)
at checkAndUpdateView (http://localhost:9876/_karma_webpack_/vendor.bundle.js:48473:14)
at callWithDebugContext (http://localhost:9876/_karma_webpack_/vendor.bundle.js:49693:42)
This error is still occurring in 1.3.0-rc.5, the regression was added in 1.2.2, https://github.com/angular/angular-cli/commit/19f04af0777391cc72d096a0e315fe87bab161c6.
If a runtime errors occur during the constructor then the proper error displays, but sourcemaps still fail to show line in TypeScript.
It would be best if the actual error and line in typescript could be referenced.
For me it's failing in addEventListner()
receiveMessage() {
this.commonService.getNativeWindow().addEventListener(
'message',
(e) => {
if(e.origin.match(/localhost/) && e.data['myIframe']) {
if(!this.bypassCookie) {
this.getConfig(e.data);
}
}
}, false)
}
zone.js:2642 XMLHttpRequest cannot load ng:///DynamicTestModule/MyComponent_Host.ngfactory.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
(anonymous) @ zone.js:2642
proto.(anonymous function) @ zone.js:1227
(anonymous) @ browser-source-map-support.js:107
(anonymous) @ browser-source-map-support.js:101
(anonymous) @ browser-source-map-support.js:107
(anonymous) @ browser-source-map-support.js:101
a @ browser-source-map-support.js:101
b @ browser-source-map-support.js:104
(anonymous) @ browser-source-map-support.js:105
f @ browser-source-map-support.js:105
ExceptionFormatter.stack @ jasmine.js:1500
stack @ jasmine.js:1645
buildExpectationResult @ jasmine.js:1610
expectationResultFactory @ jasmine.js:655
Spec.addExpectationResult @ jasmine.js:342
onException @ jasmine.js:398
onException @ jasmine.js:373
onException @ jasmine.js:1988
handleException @ jasmine.js:1992
attemptSync @ jasmine.js:1952
QueueRunner.run @ jasmine.js:1938
(anonymous) @ jasmine.js:1962
(anonymous) @ jasmine.js:1905
(anonymous) @ testing.es5.js:92
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
webpackJsonp.../../../../zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke @ async-test.js:49
webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke @ proxy.js:76
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:390
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run @ zone.js:141
(anonymous) @ testing.es5.js:87
(anonymous) @ async-test.js:38
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:424
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:191
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:498
ZoneTask.invoke @ zone.js:487
timer @ zone.js:1829
setTimeout (async)
scheduleTask @ zone.js:1839
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:235
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:258
(anonymous) @ zone.js:1865
proto.(anonymous function) @ zone.js:1227
(anonymous) @ async-test.js:36
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run @ zone.js:141
webpackJsonp.../../../../zone.js/dist/async-test.js.AsyncTestZoneSpec._finishCallbackIfDone @ async-test.js:35
webpackJsonp.../../../../zone.js/dist/async-test.js.AsyncTestZoneSpec.onHasTask @ async-test.js:68
webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.onHasTask @ proxy.js:116
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.hasTask @ zone.js:444
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate._updateTaskCount @ zone.js:464
webpackJsonp.../../../../zone.js/dist/zone.js.Zone._updateTaskCount @ zone.js:288
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:208
drainMicroTaskQueue @ zone.js:595
Promise resolved (async)
scheduleMicroTask @ zone.js:578
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:413
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:235
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:255
webpackJsonp.../../../../zone.js/dist/jasmine-patch.js.jasmine.QueueRunner.ZoneQueueRunner.execute @ jasmine-patch.js:129
queueRunnerFactory @ jasmine.js:714
TreeProcessor.execute @ jasmine.js:2426
Env.execute @ jasmine.js:776
(anonymous) @ adapter.js:336
../../../../../src/test.ts @ test.ts:32
__webpack_require__ @ bootstrap 8398b79f44fceec48211:54
webpackJsonpCallback @ bootstrap 8398b79f44fceec48211:25
(anonymous) @ main.bundle.js:1
zone.js:195 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/MyComponent_Host.ngfactory.js'.
at http://localhost:9876/_karma_webpack_/webpack:/Users/ljeff/git_repo/sandbox/angular/~/zone.js/dist/zone.js:2642:1
at XMLHttpRequest.proto.(anonymous function) [as send] (http://localhost:9876/_karma_webpack_/webpack:/Users/ljeff/git_repo/sandbox/angular/~/zone.js/dist/zone.js:1227:1)
at Array.<anonymous> (http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:107:176)
at http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:101:106
at Array.<anonymous> (http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:107:474)
at http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:101:106
at a (http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:101:312)
at b (http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:104:348)
at http://localhost:9876/base/node_modules/@angular/cli/node_modules/source-map-support/browser-source-map-support.js:105:245
at Array.map (<anonymous>)
Running cli 1.2.4
@playground as a temporary workaround you can run tests with --sourcemaps=false
to see the actual error message but lets keep this issue more generic, this issue occurs with any runtime error, as per the example. Your service/function may not be returning what you expect, you'll see a better message with sourcemaps off.
@playground I had this same issue, and when I ran ng test --sourcemaps=false
, I got feedback on the test that failed like "TypeError: Cannot read property 'count' of undefined", where I had a child component like this:
<span>{{entity.count}}</span>
Where entity
was defined in the parent component, and defined asynchronously. So I added the safe navigation operator to the property binding like {{entity?.count}}
, and that error went away.
@JSMike @nathanBrenner thanks, I will give that a try.
@nathanBrenner thanks, disabling sourcemaps for unit tests lets me now debug the actual error
I have a component with a formGroup, and I accessed its status value in my template. During unit-tests the formgroup was undefined, which caused a runtime null-pointer. The error message was the same as OP.
I have same result on 1.3.0:
sharikovvlad:ng2-diary-book svlad$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.3.0
node: 8.3.0
os: darwin x64
@angular/animations: 4.3.5
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.5
@angular/compiler: 4.3.5
@angular/core: 4.3.5
@angular/forms: 4.3.5
@angular/http: 4.3.5
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.5
@angular/platform-browser-dynamic: 4.3.5
@angular/router: 4.3.5
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.5
@angular/language-service: 4.3.5
Same inputs and outputs. I have some component with exception and I get error like topic started mentioned. I expect that I will see exception.
When the project has been ejected, how can we translate the --source=false
option into karma.conf.js
options?
https://github.com/angular/angular-cli/issues/6583 mentions a few options but nothing seems very conclusive.
Had that issue until I just reinstalled the node_modules
.
Running angular cli 1.4.9
on Windows with npm 5.5.1
, node 8.7.0
Sadly, the npm test --source=false
flag does not work for me. I still can't see the right error message. I've also tried doing rm -rf node_modules && npm cache clean && npm install
.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.4.4
node: 6.9.1
os: darwin x64
@angular/animations: 4.4.6
@angular/cdk: 2.0.0-beta.12
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/flex-layout: 2.0.0-beta.9-7dcd97b
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/material: 2.0.0-beta.12
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.4
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4
@kamok Try running ng test --sourcemaps=false
(and not using npm)
@etaiso That was it. I upgraded to the latest node and angular/cli and it still didn't work with npm test
. ng test
with the --sourcemaps=false
allows me to see the error. Thanks.
Edit: So turns out you need another --
to pass arguments into npm
scripts. So npm test -- --sourcemaps=false
is equivalent to ng test --sourcemaps=false
. More here: https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script
Whether I run ng test --sourcemaps=false
or npm test -- --sourcemaps=false
I still get [object ErrorEvent] thrown
with no further details. Any ideas?
@joey-borowicz full stack trace?
@benelliott sorry, should have been more clear. There is no stack trace, and I was hoping that --sourcemaps=false
would produce a more traceable error.
@joey-borowicz Have you tried re-enabling source maps, then using the Debug button in the Karma window and opening up your console to see the error?
@benelliott thanks, now I see that I am getting a server error
@kamok "npm test --anything" is not working. You have to use "npm test -- --anything" to pass parameters to whatever npm test
is. So in your case it will be converted to: ng test --anything
.
Or you also can just run ng test --anything
as mentioned above.
This approach, ng test -sm=false
works, but I do not think it has solved the fundamental problem. I did some experiments today, studied it in depth, and share some results @here, hoping to be helpful.
In Chrome, some additional information appeared in the browser console of Karma DEBUG runner:
ng: ///DynamicTestModule/SandboxComponent.ngfactory.js: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
I think the root cause is here.
So, I switch to Firefox. It works.
So, I think the fundamental reason here is that Chrome's cross-domain detection is stronger than Firefox, blocking the ng:///
protocol in the sourcemaps, causing this issue.
So, I think, maybe we can just replace the "ng: ///" prefix with a prefix such as "http: ///" to resolve this issue.
I found that this only happens when an error occurs during CD in my case.
This can range from things like you template referencing components that aren't in the module or having an exception thrown in a lifecycle hook or any view related errors.
to confirm this you can do
it('should fail', () => {
component.detectChanges();
component.componentInstance.throw();
expect(true).toEqual(false);
})
with your component looking like
throw(){
throw new Error('err');
}
ngOnInit(){
throw new Error('err');
}
Now if you run with ng test
the browser will hang and eventually crash, you can see the error in the chrome log.
However, if you remove the error from ngOnInit then it throws it as expected and dosen't break
then swapping to ng test --sm=false
it always works as expected
I see this error '[object ErrorEvent] thrown' when I run all tests.
There are always 1 - 3 test failing with this error, and it is not always the same tests failing. Run it a second time and other tests will fail.
If I run the spec which contains the fail test (the spec itself contains multiple tests) then the test does not fail.
Running 'ng test --sourcemaps=false' does not provide any additional information.
PS C:\ixia\ixnetwork-RestClient> ng test --sourcemaps=false
Your global Angular CLI version (1.5.0) is greater than your local
version (1.4.3). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
10% building modules 1/1 modules 0 active13 12 2017 14:28:55.497:WARN [karma]: No captured browser, open http://localhost:9876/
13 12 2017 14:28:55.506:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
13 12 2017 14:28:55.506:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 12 2017 14:28:55.511:INFO [launcher]: Starting browser Chrome 13 12 2017 14:29:11.979:WARN [karma]: No captured browser, open http://localhost:9876/
13 12 2017 14:29:13.870:INFO [Chrome 62.0.3202 (Windows 10 0.0.0)]: Connected on socket 9_9PO_RC50gBeZnsAAAA with id 50712456
Chrome 62.0.3202 (Windows 10 0.0.0) ERROR
Script error.
Chrome 62.0.3202 (Windows 10 0.0.0): Executed 140 of 166 (skipped 7) ERROR (0 secs / 3.944 secs)
Chrome 62.0.3202 (Windows 10 0.0.0) ERROR
Chrome 62.0.3202 (Windows 10 0.0.0): Executed 140 of 166 (skipped 7) ERROR (4.055 secs / 3.944 secs)
I'm using chrome, and the following version.
@angular/cli: 1.4.3
node: 8.9.1
os: win32 x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.6.1
the ng:///
prefix in source-map is added by : https://github.com/angular/angular/blob/master/packages/compiler/src/compile_metadata.ts#L683 and then loaded by the CLI via source-map-loader
.
So, I think we can convert all sourcemaps to base64 sourceMapUrl for testing.
Experiencing this issue when running an Angular app within a JavaFX Webview, as opposed to unit tests. Building with sourcemaps=false fixes the issue. JavaFx under the hood this is just plain WebKit.
Specific user agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/604.1 (KHTML, like Gecko) JavaFX/9 Safari/604.1
It would be interesting to know if anyone gets this when running with something like PhantomJS.
@limpygnome we definitely had the problem when running our unit tests with PhantomJS. But I think this also happened when running them with Chrome (with the then current version, i.e. something around version 60) so maybe not restricted to WebKit based browsers (if I remember correctly we also had this when running the tests through Firefox).
Is it recommended now to always turn off sourcemaps when running tests using ng test -sm=false
?
Hi all, if angular 2+ project has ejected, need:
in karma.conf.js in angularCli: {.. add sourcemaps: false,
for eample:
angularCli: {
environment: 'dev',
sourcemaps: false
},
I think with Angular CLI 1.5 the problem has at least gotten better. Maybe it is even resolved completely?
@UrsMetz I'm using Angular Cli 1.5.4 here and nothing has gotten better. This is pretty annoying.
I'm experiencing this issue with CLI 1.6.3. Using --sourcemaps=false
does not help at all.
For me it's failing during import ngrx StoreModule.forRoot([reducers]) to test.
Solution:
spyOn(StoreModule, 'forRoot').and.returnValue(Promise.resolve(true));
Experiencing this issue with CLI 1.6.1
1.6.6. - the error is still there, unfortunately. Disabling sourcemaps give some degree of clarity, but it's clearly just a workaround. Anyone has some ideas or guidelines on how not to get this error?
Seeing the issue with angular cli 1.6.5 on ubuntu with Chrome 64.0.3282.140
I am using angular cli v 1.6.5. In my case ng test --sourcemap=false
is not returning any error but ng test
is giving the error similar to mentioned in original issue.
As I need to generate Istanbul code coverage report, which requires sourcemap for typescript files to generate it properly, I tried to run tests using Firefox instead of Chrome and it worked well.
I'm experiencing this issue - wasted a good 2-3 hours until I found this.
Any plans to fix?
I'm facing the same issue, but with an ejected project.
How to --sourcemap=false
when running tests with karma start
?
I wrote in post before: in karma.conf.js
angularCli: {
environment: 'dev',
sourcemaps: false
},
@asmolientsev thanks, missed that.
Still reproduces on Angular CLI 1.7.3. --sourcemap=false flag resolves this issue
I saw an "Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/..
too when writing a new component test.
In my case the reason was a poorly written template with *ngIf="queryTable.data"
. Revising this to *ngIf="queryTable && queryTable.data"
solved the problem for me.
I think this confirms the observation from @Toxicable https://github.com/angular/angular-cli/issues/7296#issuecomment-347359285
@cf33 as a note, you can should use the angular operator. *ngIf="query Table?.data"
I solved this problem by using propa?.propb
instead of propa.propb
in my template, without turn off source map, and the ng://
protocol works well in Chrome.
Angular CLI v6 doesn't seem to support the --sourcemap=false
flag:
$ ng test --sourcemap=false
> Unknown option: '--sourcemap'
ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.3
Node: 8.11.2
OS: darwin x64
Angular: 6.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/build-angular 0.6.1
@angular-devkit/build-ng-packagr 0.6.3
@angular-devkit/build-optimizer 0.6.1
@angular-devkit/core 0.6.1
@angular-devkit/schematics 0.6.3
@angular/cli 6.0.3
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.0.1
@schematics/angular 0.6.3
@schematics/update 0.6.3
ng-packagr 3.0.0-rc.5
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
@danguilherme It's still there you just need to configure it via angular.json
.
@diminutivesloop Thanks, it worked!
Just for completeness, in angular.json
the property is called sourceMap
.
If the flag --sourceMap=false
(note the capital M) is passed, it works.
In angular 6, the cryptic error message related to http call is now replaced with [object ErrorEvent] thrown
Also for command line: --source-map=false
argument continues to work
EDIT: in our case we also ended up getting [object ErrorEvent] thrown
when change detection threw an error that a component is destroyed, but something tried to update the view (turned out to be not mocked setTimeout in some previous test). The correct error message was visible in chrome console, but only cryptic one in command line window. This wasn't obvious as we usually run the tests in headless chrome
any update? sourceMap=false doesn't help (angular-cli 6.0.8)
@Viktor-Bredihin it's --source-map=false
now
Using Angular CLI 1.3.2, Angular 4.4.7, and the given demo, I get
Chrome 67.0.3396 (Mac OS X 10.13.6): Executed 0 of 4 DISCONNECTED (10.003 secs / 0 secs)
instead of the failed to execute send. The above workaround still works.
We have had this issue for more than a year now. We have to switch between --source-map=true
and --source-map=false
all the time. Is there a better solution?
I have found the cause. It has nothing to do with karma, but the issue is triggered by the source-map-support
package which is installed by @angular/cli
.
The Angular source maps refer to paths like ng:///DynamicTestModule/YourComponent.ngfactory.js
which triggers CORS errors.
Should be fixed by https://github.com/evanw/node-source-map-support/pull/222 and/or by the Angular CLI.
After deleted my node_modules and install them again with yarn, I still have the same issue as described here:
Here is my package.json:
{
"name": "mywebclient",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint --type-check",
"e2e": "ng e2e",
},
"dependencies": {
"@angular/animations": "6.1.3",
"@angular/cdk": "6.4.6",
"@angular/common": "6.1.3",
"@angular/compiler": "6.1.3",
"@angular/core": "6.1.3",
"@angular/flex-layout": "6.0.0-beta.17",
"@angular/forms": "6.1.3",
"@angular/http": "6.1.3",
"@angular/material": "6.4.6",
"@angular/platform-browser": "6.1.3",
"@angular/platform-browser-dynamic": "6.1.3",
"@angular/router": "6.1.3",
"@ngx-translate/core": "10.0.2",
"@ngx-translate/http-loader": "3.0.1",
"@types/chart.js": "2.7.31",
"bootstrap": "4.1.3",
"chart.js": "2.7.2",
"chartjs-plugin-zoom": "0.6.4",
"core-js": "2.5.7",
"font-awesome": "4.7.0",
"hammerjs": "2.0.8",
"material-design-icons": "3.0.1",
"ng-event-source": "1.0.11",
"rxjs": "6.2.2",
"typedoc": "0.12.0",
"typescript": "2.9.2",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.7.4",
"@angular/cli": "6.1.4",
"@angular/compiler-cli": "6.1.3",
"@angular/language-service": "6.1.3",
"@types/jasmine": "2.8.8",
"@types/jasminewd2": "2.0.3",
"@types/node": "10.7.1",
"codelyzer": "4.4.4",
"jasmine-core": "3.2.1",
"jasmine-spec-reporter": "4.2.1",
"karma": "3.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage": "1.1.2",
"karma-coverage-istanbul-reporter": "2.0.1",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "1.1.2",
"karma-jasmine-html-reporter": "1.3.1",
"karma-json-reporter": "1.2.1",
"karma-junit-reporter": "1.2.0",
"ngx-i18nsupport": "0.17.0",
"protractor": "5.4.0",
"ts-node": "7.0.1",
"tslint": "5.11.0"
}
}
In my case the error was reported to unrelated test, tried to comment out tests until I found the cause.
The test alone (fit
) was passing but with all test running failed causing jasmine to report other test as faield - not sure why.
In my case I was missing the error handler in subscribe()
function:
service.getOperations().subscribe(() => {
fail('Should not be here.');
},
() => { /* must be defined in order to test success */ }, // after adding this the error disappeared
() => { });
I found same solution like @felikf
Closing this as I cannot reproduce locally the first issue on master:
Please note that the comments about subscription and asynchronicity in Jasmine are not CLI issues, and are working as intended. Do you need to have a done
argument in your Jasmine test handler? That might be the cause, if your tests are asynchronous and not handling Zone properly.
If you find a similar or different issue, please open a new issue so we can track that one. Original issue was fixed.
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
@playground as a temporary workaround you can run tests with
--sourcemaps=false
to see the actual error message but lets keep this issue more generic, this issue occurs with any runtime error, as per the example. Your service/function may not be returning what you expect, you'll see a better message with sourcemaps off.