angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

@angular/cli upgrade breaks karma/jasmine sourcemap reporting #14457

Closed mbenna closed 5 years ago

mbenna commented 5 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes. Sourcemaps in karma/jasmine worked fine up to and including@angular/cli 8.0.0.beta.9, but from beta.10 to current (rc.4 today) sourcemaps no longer work.

Description

Example working output from beta.9:

Expected true to be falsy.
  at UserContext.<anonymous> (src/app/app.component.spec.ts:32:18)

Example broken output from beta.10+:

Error: Expected true to be falsy.
  at <Jasmine>
  at UserContext.<anonymous> (http://localhost:9877/_karma_webpack_/main.js:304:22)
  at ZoneDelegate.invoke (http://localhost:9877/_karma_webpack_/polyfills.js:3325:26)
  at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (http://localhos...

πŸ”¬ Minimal Reproduction

πŸ”₯ Exception or Error

n/a

🌍 Your Environment

ng version:

Angular CLI: 8.0.0-rc.4
Node: 12.1.0
OS: win32 x64
Angular: 8.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-rc.4
@angular-devkit/build-angular     0.800.0-rc.4
@angular-devkit/build-optimizer   0.800.0-rc.4
@angular-devkit/build-webpack     0.800.0-rc.4
@angular-devkit/core              8.0.0-rc.4
@angular-devkit/schematics        8.0.0-rc.4
@ngtools/webpack                  8.0.0-rc.4
@schematics/angular               8.0.0-rc.4
@schematics/update                0.800.0-rc.4
rxjs                              6.5.2
typescript                        3.5.0-rc
webpack                           4.30.0

Anything else relevant?

Not that I know of.

mbenna commented 5 years ago

fwiw, I also added this to one of my spec files to help catch the problem during my test suite rather than manually noticing it has broken:

    it('source maps should work in karma / jarmine', () => {
        const err = new Error('spec')
        let shouldFail = false
        shouldFail = shouldFail || / firefox\//i.test(navigator.userAgent) // doesn't work in firefox
        shouldFail = shouldFail || / edge\//i.test(navigator.userAgent) // doesn't work in edge
        // console.log(`navigator.userAgent = ${navigator.userAgent}`)
        // Edge: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
        if (err.stack.match(/\/src\/app\/app.component.spec.ts:3[0-9]:[0-9]+/)) {
            if (shouldFail) {
                fail(`Sweet! Source maps are now working in this browser!`)
            }
        } else {
            if (!shouldFail) {
                fail(`source maps don't seem to be working! Probably a recent node_module upgrade broke them.`)
            }
        }
        // console.log(`stack = ${err.stack}`)
        // // It should look something like this:
        // stack = Error: spec
        // at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/app.component.spec.ts:44:15)
        // at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:391:1)
    })
angular-automatic-lock-bot[bot] commented 5 years ago

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.