Skip to content

ng test --environment works only once, but not on watch auto re-run #7305

@lukemadera

Description

@lukemadera

Bug Report or Feature Request (mark with an x)

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

Versions.

node --version
v6.10.1
npm --version
3.10.10
macOS (Sierra)

Repro steps.

  1. npm run test (which runs ng test --environment=local)
    This works fine (tests run successfully, using the specified environment).
  2. change a .spec test file
    This fails - it tries to re-run tests due to the change, but this time the environment is NOT used, instead the defaults environment.ts is used (which in our case leads to an error because it does not exist. Even if it did exist, it still is a bug as the proper environment is not being used).

The log given by the failure.

npm test

> pl-components-ng2@2.0.14 test /Users/lukemadera/Documents/code/presencelearning/pl-components-ng2
> ng test --environment=local

 10% building modules 1/1 modules 0 active08 08 2017 11:06:31.697:WARN [karma]: No captured browser, open http://localhost:9876/
08 08 2017 11:06:35.008:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
08 08 2017 11:06:35.010:INFO [launcher]: Launching browser Chrome with unlimited concurrency
08 08 2017 11:06:35.015:INFO [launcher]: Starting browser Chrome
[../../../../../src recursive \.spec\.ts$] ./src \.spec\.ts$ 1.32 kB {main} [built]      
[../../../../../src/lib/pipes/commify.pipe.spec.ts] ./src/lib/pipes/commify.pipe.spec.ts 1.2 kB {main} [optional] [built]
[../../../../../src/lib/pl-button/index.spec.ts] ./src/lib/pl-button/index.spec.ts 135 bytes {main} [optional] [built]
[../../../../../src/lib/utilities/object.spec.ts] ./src/lib/utilities/object.spec.ts 1.74 kB {main} [optional] [built]
[../../../../../src/polyfills.ts] ./src/polyfills.ts 2.53 kB {polyfills} [built]
[../../../../../src/test.ts] ./src/test.ts 1.02 kB {main} [built]
[../../../../zone.js/dist/async-test.js] ./node_modules/zone.js/dist/async-test.js 3.23 kB {vendor} [built]
[../../../../zone.js/dist/fake-async-test.js] ./node_modules/zone.js/dist/fake-async-test.js 16.3 kB {vendor} [built]
[../../../../zone.js/dist/jasmine-patch.js] ./node_modules/zone.js/dist/jasmine-patch.js 6.36 kB {vendor} [built]
[../../../../zone.js/dist/long-stack-trace-zone.js] ./node_modules/zone.js/dist/long-stack-trace-zone.js 6.22 kB {vendor} [built]
   [0] multi ./src/polyfills.ts 28 bytes {polyfills} [built]
[../../../../zone.js/dist/proxy.js] ./node_modules/zone.js/dist/proxy.js 5.6 kB {vendor} [built]
[../../../../zone.js/dist/sync-test.js] ./node_modules/zone.js/dist/sync-test.js 1.41 kB {vendor} [built]
[../../../core/@angular/core/testing.es5.js] ./node_modules/@angular/core/@angular/core/testing.es5.js 39.7 kB {vendor} [built]
[../../../platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js] ./node_modules/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js 3.61 kB {vendor} [built]
    + 930 hidden modules

WARNING in ./node_modules/jasmine/lib/jasmine.js
93:4-17 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jasmine/lib/jasmine.js
99:4-17 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jasmine/lib/jasmine.js
106:17-48 Critical dependency: the request of a dependency is an expression
08 08 2017 11:06:50.457:WARN [karma]: No captured browser, open http://localhost:9876/
08 08 2017 11:06:50.709:INFO [Chrome 56.0.2924 (Mac OS X 10.12.3)]: Connected on socket GYNA0Z9MVmEi5n5VAAAA with id 44599402
Chrome 56.0.2924 (Mac OS X 10.12.3): Executed 27 of 27 SUCCESS (0.495 secs / 0.461 secs)
[../../../../../src recursive \.spec\.ts$] ./src \.spec\.ts$ 1.32 kB {main} [built]
[../../../../../src/lib/pipes/commify.pipe.spec.ts] ./src/lib/pipes/commify.pipe.spec.ts 1.2 kB {main} [optional]
[../../../../../src/lib/pl-button/index.spec.ts] ./src/lib/pl-button/index.spec.ts 135 bytes {main} [optional]
[../../../../../src/lib/utilities/object.spec.ts] ./src/lib/utilities/object.spec.ts 1.74 kB {main} [optional]
[../../../../../src/polyfills.ts] ./src/polyfills.ts 2.53 kB {polyfills}
[../../../../../src/test.ts] ./src/test.ts 1.02 kB {main}
[../../../../zone.js/dist/async-test.js] ./node_modules/zone.js/dist/async-test.js 3.23 kB {vendor}
[../../../../zone.js/dist/fake-async-test.js] ./node_modules/zone.js/dist/fake-async-test.js 16.3 kB {vendor}
[../../../../zone.js/dist/jasmine-patch.js] ./node_modules/zone.js/dist/jasmine-patch.js 6.36 kB {vendor}
[../../../../zone.js/dist/long-stack-trace-zone.js] ./node_modules/zone.js/dist/long-stack-trace-zone.js 6.22 kB {vendor}
   [0] multi ./src/polyfills.ts 28 bytes {polyfills}
[../../../../zone.js/dist/proxy.js] ./node_modules/zone.js/dist/proxy.js 5.6 kB {vendor}
[../../../../zone.js/dist/sync-test.js] ./node_modules/zone.js/dist/sync-test.js 1.41 kB {vendor}
[../../../core/@angular/core/testing.es5.js] ./node_modules/@angular/core/@angular/core/testing.es5.js 39.7 kB {vendor}
[../../../platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js] ./node_modules/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js 3.61 kB {vendor}
    + 930 hidden modules

WARNING in ./node_modules/jasmine/lib/jasmine.js
93:4-17 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jasmine/lib/jasmine.js
99:4-17 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/jasmine/lib/jasmine.js
106:17-48 Critical dependency: the request of a dependency is an expression

ERROR in ./src/environments/environment.ts
Module build failed: Error: ENOENT: no such file or directory, open '/Users/lukemadera/Documents/code/presencelearning/pl-components-ng2/src/environments/environment.ts'
    at Error (native)
 @ ./src/lib/pl-browser/pl-browser.service.ts 18:20-61
 @ ./src/lib/pl-browser/index.ts
 @ ./src/lib/pl-browser/index.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts

Desired functionality.

The environment.local.ts specified by the --environment flag is used ALL the time, not just on the first run. Which thus leads to a successful test watcher that will auto re-run tests on changes without breaking, as it does now.

Mention any other details that might be useful.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions