Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma testing output not the same in angular/cli versions after 1.0.6 #6583

Closed
whyboris opened this issue Jun 5, 2017 · 40 comments · Fixed by #6968
Closed

Karma testing output not the same in angular/cli versions after 1.0.6 #6583

whyboris opened this issue Jun 5, 2017 · 40 comments · Fixed by #6968
Assignees
Labels
effort2: medium (days) freq2: medium P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity5: regression type: bug/fix

Comments

@whyboris
Copy link

whyboris commented Jun 5, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Summary:

@angular/cli: 1.1.0 (replicated on 1.2.0-beta.0)
node: v6.9.1 (replicated on 8.0.0)
npm: 4.6.1 (replicated on 5.0.0)
OS: macOS Sierra 10.12.4 (replicated on Windows 7 too)

Full:

@angular/cli: 1.1.0
node: 6.9.1
os: darwin x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/compiler-cli: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/platform-server: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.1.0

Repro steps.

Create a project, write some unit tests, make at least one test fail (e.g. expect true to be false), run ng test

karma.conf.js has these features:

    frameworks: ['jasmine', '@angular/cli'],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    reporters: ['progress'],

package.json has these features (probably irrelevant since older versions of these packages were working fine too before the cli upgrade):

    "jasmine-core": "~2.6.2",
    "karma": "~1.7.0",
    "karma-jasmine": "~1.1.0",
    "karma-cli": "~1.0.1",

The log given by the failure.

When using later versions of @angular/cli the ng test output looks something like this:

        _getByKey@http://localhost:9876/_karma_webpack_/vendor.bundle.js:34382:41
        get@http://localhost:9876/_karma_webpack_/vendor.bundle.js:34251:30
        get@http://localhost:9876/_karma_webpack_/vendor.bundle.js:35219:55
        resolveDep@http://localhost:9876/_karma_webpack_/vendor.bundle.js:42680:48
        createClass@http://localhost:9876/_karma_webpack_/vendor.bundle.js:42536:45
        createDirectiveInstance@http://localhost:9876/_karma_webpack_/vendor.bundle.js:42364:48
        createViewNodes@http://localhost:9876/_karma_webpack_/vendor.bundle.js:43727:72
        createRootView@http://localhost:9876/_karma_webpack_/vendor.bundle.js:43632:20
        callWithDebugContext@http://localhost:9876/_karma_webpack_/vendor.bundle.js:44847:47
        debugCreateRootView@http://localhost:9876/_karma_webpack_/vendor.bundle.js:44307:32
        create@http://localhost:9876/_karma_webpack_/vendor.bundle.js:41553:60
        initComponent@http://localhost:9876/_karma_webpack_/vendor.bundle.js:46642:55
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2732:31
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:106204:45
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2731:40
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:35790:43
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2731:40
        run@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2482:49
        run@http://localhost:9876/_karma_webpack_/vendor.bundle.js:35658:65
        createComponent@http://localhost:9876/_karma_webpack_/vendor.bundle.js:46645:61
        createComponent@http://localhost:9876/_karma_webpack_/vendor.bundle.js:46449:44

Desired functionality.

When using @angular/cli 1.0.6 (and 1.0.1 and earlier) the output of ng test would look something like this:

        _throwOrNull@webpack:///~/@angular/core/@angular/core.es5.js:2770:0 <- src/test.ts:4787:45
        _getByKeyDefault@webpack:///~/@angular/core/@angular/core.es5.js:2809:0 <- src/test.ts:4826:37
        _getByKey@webpack:///~/@angular/core/@angular/core.es5.js:2741:0 <- src/test.ts:4758:41
        get@webpack:///~/@angular/core/@angular/core.es5.js:2610:0 <- src/test.ts:4627:30
        get@webpack:///~/@angular/core/@angular/core.es5.js:3578:0 <- src/test.ts:5595:55
        resolveDep@webpack:///~/@angular/core/@angular/core.es5.js:11039:0 <- src/test.ts:13056:48
        createClass@webpack:///~/@angular/core/@angular/core.es5.js:10895:0 <- src/test.ts:12912:45
        createDirectiveInstance@webpack:///~/@angular/core/@angular/core.es5.js:10723:21 <- src/test.ts:12740:48
        createViewNodes@webpack:///~/@angular/core/@angular/core.es5.js:12086:33 <- src/test.ts:14103:72
        createRootView@webpack:///~/@angular/core/@angular/core.es5.js:11991:0 <- src/test.ts:14008:20
        callWithDebugContext@webpack:///~/@angular/core/@angular/core.es5.js:13206:25 <- src/test.ts:15223:47
        debugCreateRootView@webpack:///~/@angular/core/@angular/core.es5.js:12666:0 <- src/test.ts:14683:32
        create@webpack:///~/@angular/core/@angular/core.es5.js:9912:25 <- src/test.ts:11929:60
        initComponent@webpack:///~/@angular/core/@angular/core/testing.es5.js:803:0 <- src/test.ts:17338:55
        invoke@webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:1546:31
        onInvoke@webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:96647:45
        invoke@webpack:///~/zone.js/dist/zone.js:390:0 <- src/polyfills.ts:1545:40
        onInvoke@webpack:///~/@angular/core/@angular/core.es5.js:4149:0 <- src/test.ts:6166:43
        invoke@webpack:///~/zone.js/dist/zone.js:390:0 <- src/polyfills.ts:1545:40

Mention any other details that might be useful.

Please let me know if I should clarify anything. I confirmed the error is caused by angular-cli: when I rolled back to version 1.0.6 the ng test unit test errors were logged as they were logged previously (as desired).

@whyboris whyboris changed the title Karma testing output not the same in versions after 1.0.6 Karma testing output not the same in angular/cli versions after 1.0.6 Jun 5, 2017
@whyboris
Copy link
Author

whyboris commented Jun 5, 2017

To explain the relevancy of this problem:
Previously, at least one line of the output would show the location of the error in a file I created, e.g:
webpack:///src/app/dashboard/stats/stats.component.spec.ts:26:32 <- src/test.ts:43754:37
(component.spec.ts is I file I created).
With the updated cli there is no record of where the error occurred, every file is a .bundle.js file

@filipesilva
Copy link
Contributor

I'm sorry, I don't understand what you're trying to show here. I don't see any error message on the logs your provided... there seems to be a stack trace perhaps? But I don't know what for.

Can you set up a github simple repo showing this issue please? E.g. a project created from ng new with the minimum set of changes needed to see the problem, and instructions that I can follow to see it.

@filipesilva filipesilva self-assigned this Jun 6, 2017
@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jun 6, 2017
@whyboris
Copy link
Author

whyboris commented Jun 6, 2017

Thank you for the feedback. I will try to create a project to reproduce the steps today or tomorrow. Sorry my original description was not clear enough.

The key problem is that the stack trace previously (in 1.0.6 and before) would include the reference to a file that I created that had the failing test, and the location of where the error occurred (e.g. stats.component.spec.ts:26:32) while with CLI version 1.1.0 and above, the stack trace contains no reference to any file I created.

This is a problem for when I write unit tests.

@whyboris
Copy link
Author

whyboris commented Jun 6, 2017

Issue reproduced with a clean-install using command ng new cli106:
https://github.com/whyboris/cli106
Generated using globally-installed @angular/cli@1.0.6 with no changes except the addition of a failing test:
https://github.com/whyboris/cli106/commit/ffb9133cb2fd099e26e38cf759d1e9a2b1471448
This repository will generate errors that are expected:
1.0.6 error log:

Expected 'hello there' to be 'hello!'.
at Object.<anonymous> (webpack:///src/app/app.component.spec.ts:45:30 <- src/test.ts:51489:37)
at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:1546:26)
at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:52534:39)

notice the app.component.spec.ts while the 45:30 is not the correct location of the error, at least the file where the error occurred is easily seen.

Now change the package.json devDependency from "@angular/cli": "1.0.6", to "@angular/cli": "1.1.0", and run npm install and run ng test

1.1.0 error log:

Expected 'hello there' to be 'hello!'.
at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:106:37)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2732:26)
at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/vendor.bundle.js:54685:39)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2731:32)

Notice that the stack trace no longer includes app.component.spec.ts

@filipesilva
Copy link
Contributor

Got it, seems like a sourcemap problem. Will investigate.

@filipesilva filipesilva added command: test P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity5: regression type: bug/fix effort1: easy (hours) and removed needs: repro steps We cannot reproduce the issue with the information given labels Jun 12, 2017
ryzy added a commit to ashB100/letter-position-game that referenced this issue Jun 18, 2017
ashB100 pushed a commit to ashB100/letter-position-game that referenced this issue Jun 18, 2017
ryzy added a commit to ashB100/letter-position-game that referenced this issue Jun 18, 2017
@filipesilva
Copy link
Contributor

@whyboris I tried your repro but I can't see the original file either:

kamik@T460p MINGW64 /d/sandbox
$ git clone https://github.com/whyboris/cli106.git
Cloning into 'cli106'...
remote: Counting objects: 64, done.
remote: Total 64 (delta 0), reused 0 (delta 0), pack-reused 64
Unpacking objects: 100% (64/64), done.

kamik@T460p MINGW64 /d/sandbox
$ cd cli106/

kamik@T460p MINGW64 /d/sandbox/cli106 (master)
$ yarn
yarn install v0.24.6
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.2: The platform "win32" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 55.47s.

kamik@T460p MINGW64 /d/sandbox/cli106 (master)
$ ng test
 10% building modules 1/1 modules 0 active03 07 2017 21:00:34.588:WARN [karma]: No captured browser, open http://localhost:9876/
03 07 2017 21:00:34.600:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
03 07 2017 21:00:34.601:INFO [launcher]: Launching browser Chrome with unlimited concurrency
03 07 2017 21:00:34.608:INFO [launcher]: Starting browser Chrome
03 07 2017 21:00:43.461:WARN [karma]: No captured browser, open http://localhost:9876/
03 07 2017 21:00:43.938:INFO [Chrome 59.0.3071 (Windows 10 0.0.0)]: Connected on socket DPGAAF7m1c0C6XjfAAAA with id 24901784
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:106:37)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/cli106/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/cli106/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/vendor.bundle.js:56763:39)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/cli106/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2703:32)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 4 of 4 (1 FAILED) (0 secs / 0.149 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:106:37)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/cli106/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/cli106/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/vendor.bundle.js:56763:39)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 4 of 4 (1 FAILED) (0.114 secs / 0.149 secs)

Does this repro still work for you?

If you still have an old version that works, maybe there's something different in the dependencies. Could you put the result of npm ls somewhere I could see?

Also, what version of chrome are you using?

@whyboris
Copy link
Author

whyboris commented Jul 5, 2017

Ran yarn
My current ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.6
node: 6.9.1
os: darwin x64
@angular/common: 4.2.5
@angular/compiler: 4.2.5
@angular/core: 4.2.5
@angular/forms: 4.2.5
@angular/http: 4.2.5
@angular/platform-browser: 4.2.5
@angular/platform-browser-dynamic: 4.2.5
@angular/router: 4.2.5
@angular/cli: 1.0.6
@angular/compiler-cli: 4.2.5

Note @angular/cli: 1.0.6
Ran npm test:

> cli106@0.0.0 test /Users/byakubchik/Desktop/angularclibroken/cli106
> ng test

05 07 2017 11:00:33.948:WARN [karma]: No captured browser, open http://localhost:9876/  
05 07 2017 11:00:33.963:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
05 07 2017 11:00:33.964:INFO [launcher]: Launching browser Chrome with unlimited concurrency
05 07 2017 11:00:34.014:INFO [launcher]: Starting browser Chrome
05 07 2017 11:00:34.751:INFO [Chrome 59.0.3071 (Mac OS X 10.12.4)]: Connected on socket oItKCpHByqdcfQpyAAAA with id 54558429
Chrome 59.0.3071 (Mac OS X 10.12.4) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (webpack:///src/app/app.component.spec.ts:45:30 <- src/test.ts:51489:37)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:1546:26)
            at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:52534:39)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:390:0 <- src/polyfills.ts:1545:32)
Chrome 59.0.3071 (Mac OS X 10.12.4): Executed 4 of 4 (1 FAILED) (0 secs / 0.151 secs)
Chrome 59.0.3071 (Mac OS X 10.12.4) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (webpack:///src/app/app.component.spec.ts:45:30 <- src/test.ts:51489:37)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:1546:26)
            at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:52534:39)
Chrome 59.0.3071 (Mac OS X 10.12.4): Executed 4 of 4 (1 FAILED) (0.273 secs / 0.151 secs)

Notice app.component.spec.ts shows up

@whyboris
Copy link
Author

whyboris commented Jul 5, 2017

Updated package.json to "@angular/cli": "1.1.0",

Ran yarn. Now ng -v is:

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.1.0
node: 6.9.1
os: darwin x64
@angular/common: 4.2.5
@angular/compiler: 4.2.5
@angular/core: 4.2.5
@angular/forms: 4.2.5
@angular/http: 4.2.5
@angular/platform-browser: 4.2.5
@angular/platform-browser-dynamic: 4.2.5
@angular/router: 4.2.5
@angular/cli: 1.1.0
@angular/compiler-cli: 4.2.5

Note @angular/cli: 1.1.0
Current output of npm test is:

05 07 2017 11:06:30.226:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
05 07 2017 11:06:30.227:INFO [launcher]: Launching browser Chrome with unlimited concurrency
05 07 2017 11:06:30.232:INFO [launcher]: Starting browser Chrome
05 07 2017 11:06:35.519:WARN [karma]: No captured browser, open http://localhost:9876/  
05 07 2017 11:06:35.643:INFO [Chrome 59.0.3071 (Mac OS X 10.12.4)]: Connected on socket J62zAKH9GB4fg0UTAAAA with id 92735878
Chrome 59.0.3071 (Mac OS X 10.12.4) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:106:37)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2732:26)
            at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/vendor.bundle.js:56791:39)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2731:32)
Chrome 59.0.3071 (Mac OS X 10.12.4): Executed 4 of 4 (1 FAILED) (0 secs / 0.16 secs)
Chrome 59.0.3071 (Mac OS X 10.12.4) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:106:37)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2732:26)
            at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/vendor.bundle.js:56791:39)
Chrome 59.0.3071 (Mac OS X 10.12.4): Executed 4 of 4 (1 FAILED) (0.188 secs / 0.16 secs)

Notice app.component.spec.ts is absent from stack trace.

@whyboris
Copy link
Author

whyboris commented Jul 6, 2017

To summarize: the repo https://github.com/whyboris/cli106 (master branch) still works -- installs with cli 1.0.6 and shows expected behavior. After manually updating to cli 1.1.0 (or later version) and running npm install or yarn the stack trace is no longer as informative as before.

Please let me know if you have any (more) questions.

@mike-bresnahan
Copy link

I have experienced the same issue and have stayed with 1.0.6 for the time being. Related to this issue, I have never seen useful file and line number information displayed inside the browser when running tests. I have always relied on the information displayed in the console. When using 1.0.6, the stack traces in the chrome look like this:

Error: Expected true to be false.
    at stack (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2176:17)
    at buildExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2146:14)
    at Spec.expectationResultFactory (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:766:18)
    at Spec.addExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:444:34)
    at Expectation.addExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:710:21)
    at Expectation.toBe (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2099:12)
    at Object.<anonymous> (http://localhost:9876/base/src/test.ts?4d87511513f4dc37c560862c452aa35472ab2964:24611:62)
    at ZoneDelegate.invoke (http://localhost:9876/base/src/polyfills.ts?b839d5bbaeb4514c1aea80141a9b6907e94b1f97:3039:26)
    at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (http://localhost:9876/base/src/test.ts?4d87511513f4dc37c560862c452aa35472ab2964:88782:39)
    at ZoneDelegate.invoke (http://localhost:9876/base/src/polyfills.ts?b839d5bbaeb4514c1aea80141a9b6907e94b1f97:3038:32)

and like this in the console:

Chrome 59.0.3071 (Windows 7 0.0.0) DateOfBirthInputComponent when initial value is undefined and field is not required validate should return true if dob is null FAILED
        Expected true to be false.
            at Object.<anonymous> (webpack:///src/app/activate/account-info/date-of-birth-input.component.spec.ts:110:61 <- src/test.ts:24611:62)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:3039:26)
            at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:88782:39)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:390:0 <- src/polyfills.ts:3038:32)
Chrome 59.0.3071 (Windows 7 0.0.0): Executed 177 of 433 (1 FAILED) (0 secs / 0.268 secs)
Chrome 59.0.3071 (Windows 7 0.0.0) DateOfBirthInputComponent when initial value is undefined and field is not required validate should return true if dob is null FAILED
        Expected true to be false.
            at Object.<anonymous> (webpack:///src/app/activate/account-info/date-of-birth-input.component.spec.ts:110:61 <- src/test.ts:24611:62)
            at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:391:0 <- src/polyfills.ts:3039:26)
            at ProxyZoneSpec.Array.concat.ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:88782:39)
Chrome 59.0.3071 (Windows 7 0.0.0): Executed 432 of 433 (1 FAILED) (skipped 1) (2.427 secs / 0.591 secs)

@filipesilva
Copy link
Contributor

Got it, was able to reproduce now. Dug into it a bit and think I know the cause. It's a complicated problem to solve, might take a bit.

@filipesilva
Copy link
Contributor

I have a solution for now:

  • npm i -D karma-source-map-support
  • in karma.conf.js add 'source-map-support' to the frameworks array
  • in karma.conf.js add require('karma-source-map-support'), to the plugins array

It will show you the original file, but in an weird URL (http://localhost:9876/_karma_webpack_/webpack:/src/app/app.component.spec.ts:46:31):

Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/app.component.spec.ts:46:31)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/~/zone.js/dist/zone.js:391:1)
            at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/~/zone.js/dist/proxy.js:79:1)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/~/zone.js/dist/zone.js:390:1)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 4 of 4 (1 FAILED) (0 secs / 0.416 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent hello function should set title to hello FAILED
        Expected 'hello there' to be 'hello!'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/app.component.spec.ts:46:31)
            at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/~/zone.js/dist/zone.js:391:1)
            at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/~/zone.js/dist/proxy.js:79:1)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 4 of 4 (1 FAILED) (0.441 secs / 0.416 secs)

Brocco pushed a commit that referenced this issue Jul 19, 2017
#6160 broke `ng test` sourcemaps in Chrome, this PR fixes it.

Before:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:38:43.942:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:38:43.945:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:38:43.953:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:54.099:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket Xdep72ofT_Q7MWBHAAAA with id 76010950
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
ost:9876/_karma_webpack_/vendor.bundle.js:56735:39)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.162 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.225 secs / 0.204 secs)
```

After:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:37:59.478:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:37:59.481:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:37:59.487:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:08.559:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket ixHN4NzVFTEW1iYiAAAA with id 92819713
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
ter-project/node_modules/zone.js/dist/proxy.js:76:1)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.367 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.421 secs / 0.4 secs)
```

Fix #6583
@markwhitfeld
Copy link

Awesome! Thanks! Please let us know when this is released.

Brocco pushed a commit to Brocco/angular-cli that referenced this issue Jul 20, 2017
angular#6160 broke `ng test` sourcemaps in Chrome, this PR fixes it.

Before:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:38:43.942:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:38:43.945:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:38:43.953:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:54.099:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket Xdep72ofT_Q7MWBHAAAA with id 76010950
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
ost:9876/_karma_webpack_/vendor.bundle.js:56735:39)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.162 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.225 secs / 0.204 secs)
```

After:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:37:59.478:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:37:59.481:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:37:59.487:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:08.559:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket ixHN4NzVFTEW1iYiAAAA with id 92819713
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
ter-project/node_modules/zone.js/dist/proxy.js:76:1)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.367 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.421 secs / 0.4 secs)
```

Fix angular#6583
@whyboris
Copy link
Author

whyboris commented Jul 20, 2017

Closed by release 1.2.2 https://github.com/angular/angular-cli/releases/tag/v1.2.2 👍

@jnizet
Copy link
Contributor

jnizet commented Jul 21, 2017

On a brand new project created with 1.2.2, I still can't see any original source file in the stack trace, and when debugging in Chrome, the original source files are not listed either in the sources panel:

Chrome 59.0.3071 (Mac OS X 10.12.5) AppComponent should have as title 'app' FAILED
	Expected 'app' to equal 'app2'.
	    at Object.<anonymous> (http://localhost:9877/_karma_webpack_/main.bundle.js:90:27)
	    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9877/_karma_webpack_/polyfills.bundle.js:2801:26)
	    at AsyncTestZoneSpec.webpackJsonp.../../../../zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (http://localhost:9877/_karma_webpack_/vendor.bundle.js:2643:39)
	    at ProxyZoneSpec.webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9877/_karma_webpack_/vendor.bundle.js:3416:39)
Chrome 59.0.3071 (Mac OS X 10.12.5): Executed 2 of 3 (1 FAILED) (0 secs / 0.193 secs)
Chrome 59.0.3071 (Mac OS X 10.12.5) AppComponent should have as title 'app' FAILED
	Expected 'app' to equal 'app2'.
	    at Object.<anonymous> (http://localhost:9877/_karma_webpack_/main.bundle.js:90:27)
	    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9877/_karma_webpack_/polyfills.bundle.js:2801:26)
	    at AsyncTestZoneSpec.webpackJsonp.../../../../zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (http://localhost:9877/_karma_webpack_/vendor.bundle.js:2643:39)
Chrome 59.0.3071 (Mac OS X 10.12.5): Executed 3 of 3 (1 FAILED) (0.263 secs / 0.234 secs)

@whyboris
Copy link
Author

@filipesilva can confirm the problem persists
Even after adding what you recommended above:

in karma.conf.js add 'source-map-support' to the frameworks array
in karma.conf.js add require('karma-source-map-support'), to the plugins array

(even tried placing source-map-support in different locations of the array in case that mattered). Even added "karma-source-map-support": "1.2.0", to devDependencies just in case.

Currently we have:
@angular/cli: 1.2.2
@angular/*: 4.3.1

Output still contains no note of original file where the error is:

PhantomJS 2.1.1 (Mac OS X 0.0.0) HashtagsComponent onSelect(hashtag) should update hashtag based on input FAILED
        Expected false to be true.
        http://localhost:9876/_karma_webpack_/main.bundle.js:5192:44
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2769:31
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:72353:45
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2768:40
...

@filipesilva
Copy link
Contributor

I think I know what happened. #6862 ended up not being in 1.2.2 either, and #6968 built on it. I'll try to get this sorted. Thanks for keeping on top of this 👍

@whyboris
Copy link
Author

Thank you @filipesilva for your work. Let me know if there's anything you'd like me to test out.

@filipesilva
Copy link
Contributor

1.2.3 is out which should sort everything out. Let me know if problems still persist.

@diminutivesloop
Copy link

After updating to 1.2.3 and installing karma-source-map-support I get sourcemaps when testing in Chrome. (Interestingly I didn't have to update karma.conf.js). However I still get no meaningful stack-traces when running tests in PhantomJS.

@whyboris
Copy link
Author

whyboris commented Jul 24, 2017

@diminutivesloop -- precisely what I noticed. For example:
Output in console when browsers: ['Chrome'], in karma.conf.js:

Chrome 59.0.3071 (Mac OS X 10.12.4) HashtagsComponent onSelect(hashtag) should update hashtag based on input FAILED
        Expected false to be true.
            at Object.<anonymous> Users/byakubchik/Desktop/forbespress2/publish/src/app/compose/hashtags/hashtags.component.spec.ts:116:34)
            at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke Users/byakubchik/Desktop/forbespress2/publish/node_modules/zone.js/dist/zone.js:391:1)
            at ProxyZoneSpec.webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke Users/byakubchik/Desktop/forbespress2/publish/node_modules/zone.js/dist/proxy.js:79:1)
            at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke Users/byakubchik/Desktop/forbespress2/publish/node_modules/zone.js/dist/zone.js:390:1)

(note hashtags.component.spec.ts is present in output, where the failed test occurs)

Output when browsers: ['PhantomJS'], in karma.conf.js:

PhantomJS 2.1.1 (Mac OS X 0.0.0) HashtagsComponent onSelect(hashtag) should update hashtag based on input FAILED
        Expected false to be true.
        http://localhost:9876/_karma_webpack_/main.bundle.js:5192:44
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2769:31
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:72353:45
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2768:40
        run@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2519:49
        http://localhost:9876/_karma_webpack_/vendor.bundle.js:72232:37
        http://localhost:9876/_karma_webpack_/vendor.bundle.js:126773:31
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2769:31
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:71769:45
        onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:72350:47
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2768:40
        run@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2519:49
        http://localhost:9876/_karma_webpack_/vendor.bundle.js:126768:28
        http://localhost:9876/_karma_webpack_/vendor.bundle.js:71758:46
        invokeTask@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2802:36
        runTask@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2569:57
        invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2864:45
        timer@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:3918:34

for the same failed test!

@filipesilva
Copy link
Contributor

filipesilva commented Jul 24, 2017

Yes, there should be no need to modify karma.conf.js with 1.2.3.

I don't think I can fix sourcemap reporting on PhantomJS unfortunately. That would require a new karma feature to be implemented (karma-runner/karma#2774).

What I can say is that Chrome Headless (available now in Linux and OSX and on the next version of Windows) should overall be a better option to PhantomJS.

@filipesilva
Copy link
Contributor

Also AFAIK there is no sourcemap trouble with Firefox and 1.2.3.

@whyboris
Copy link
Author

whyboris commented Jul 24, 2017

I just successfully solved the problem by going to Chrome Headless.
Easy to do -- just a small change to karma.conf.js
Instructions: http://cvuorinen.net/2017/05/running-angular-tests-in-headless-chrome/

ps - PhantomJS hasn't had a new release since January 2016

@filipesilva
Copy link
Contributor

That is very similar to the changes I did in #7084 to use headless in our travis setups.

@jgreene-cwt
Copy link

Hi - I'm trying to come up to speed on Karma/Jasmine, and based on the responses in this thread, I think I'm pretty current with my angular.

@angular/cli: 1.3.0
node: 7.10.1
os: linux x64
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/router: 4.3.4
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.4

I'm running Ubuntu 16.04 in a VirtualBox VM on my Windows 7 host (wouldn't think that would be relevant).

When rewriting my first Jasmine test to fail, in Chrome Developer Tools (rt-click --> Inspect), I do see the failure reported with a weird path, as you mention above.

My results:
Uncaught Expected 0 to be 1. at Object.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/demo/src/app/compute.spec.ts:7:24) at...

From @filipesilva above:
It will show you the original file, but in an weird URL (http://localhost:9876/_karma_webpack_/webpack:/src/app/app.component.spec.ts:46:31):

When i click on this link, I am supposed to be mapped back to the line of code that generates the error, but instead the browser page loads with 'Not found'.

I installed the karma-source-map-support module as you suggested, although I infer from your later post that it should not be necessary to install, nor to modify karma.conf.js at all starting with @angular/cli version 1.2.3. Shouldn't I be able to successfully link to the code that is in error by following that link with the "weird path"? Did I understand you correctly @filipesilva ? Thank you for any clarification or guidance.

@whyboris
Copy link
Author

I'm unsure whether what you've discovered is a separate issue or not.
The original issue was opened because the output would not include the name of the component file.
Since you are seeing compute.spec.ts:7:24 you are not experiencing the issue I was originally complaining about.

@jbandi
Copy link

jbandi commented Sep 21, 2017

In a new project generated with Angular CLI 1.4.2 I can't debug the TypeScript files in Firefox.
Firefox does not let me set breakpoints in the ts-files...
I tested in Firefox Developer Edition 56.0b8 and in Firefox 55.0.3.

@jbandi
Copy link

jbandi commented Oct 2, 2017

Maybe the issue is not with the Angular CLI but rather with Firefox.

With Angular CLI 1.4.4 I can successfully set breakpoints and debug TypeScript sources in Chrome, Safari and Edge. Only Firefox does not allow me to set breakpoints.

Still, with Angular CLI 1.0.6 it is working in all browsers including Firefox.

dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
angular#6160 broke `ng test` sourcemaps in Chrome, this PR fixes it.

Before:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:38:43.942:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:38:43.945:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:38:43.953:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:54.099:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket Xdep72ofT_Q7MWBHAAAA with id 76010950
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
ost:9876/_karma_webpack_/vendor.bundle.js:56735:39)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.162 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> (http://localhost:9876/_karma_webpack_/main.bundle.js:89:27)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9
876/_karma_webpack_/polyfills.bundle.js:2704:26)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke (
http://localhost:9876/_karma_webpack_/vendor.bundle.js:55972:39)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localh
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.225 secs / 0.204 secs)
```

After:
```
kamik@T460p MINGW64 D:/sandbox/master-project (master)
$ ng test --sr
 10% building modules 1/1 modules 0 active13 07 2017 16:37:59.478:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
13 07 2017 16:37:59.481:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 07 2017 16:37:59.487:INFO [launcher]: Starting browser Chrome                                                    13 07 2017 16:38:08.559:INFO [Chrome 59.0.
3071 (Windows 10 0.0.0)]: Connected on socket ixHN4NzVFTEW1iYiAAAA with id 92819713
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
ter-project/node_modules/zone.js/dist/proxy.js:76:1)
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 2 of 3 (1 FAILED) (0 secs / 0.367 secs)
Chrome 59.0.3071 (Windows 10 0.0.0) AppComponent should have as title 'app' FAILED
        Expected 'app' to equal 'forced bug'.
            at Object.<anonymous> D:/sandbox/master-project/src/app/app.component.spec.ts:23:23)
            at ZoneDelegate.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke D:/sandbox/master-p
roject/node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/async-test.js.AsyncTestZoneSpec.onInvoke D
:/sandbox/master-project/node_modules/zone.js/dist/async-test.js:49:1)
            at ProxyZoneSpec.webpackJsonp.../../../../../../../sandbox/master-project/node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke D:/sandbox/mas
Chrome 59.0.3071 (Windows 10 0.0.0): Executed 3 of 3 (1 FAILED) (0.421 secs / 0.4 secs)
```

Fix angular#6583
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) freq2: medium P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants