question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vonbothcommented, Sep 14, 2017

+1 This also affects the ‘serve’ command: ng serve --env=local works for the first time but on any file change ‘watch’ re-builds using the default environment.ts

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to execute only one test spec with angular-cli
E.g. to run only tests of the folders shared or search inside src/app, use ng test --include='src/app/{shared,search}/*. spec. ts' . You may ...
Read more >
ng test
Option Description Value Type Defau... ‑‑browsers Override which browsers tests are run against. string ‑‑code‑coverage Output a code coverage report. boolean false ‑‑code‑coverage‑exclude Globs to exclude...
Read more >
The ultimate guide to set up your Angular library project
By default, the Angular CLI provides us the ng test command which we can execute to run our test. But what about coverage?...
Read more >
End-to-end testing with Cypress - Testing Angular
If you make changes on the test files, Cypress automatically re-runs the tests. This command is typically used in the development environment.
Read more >
Configuring Jest
Node.js core modules, like fs , are not mocked by default. ... By default, Jest runs all tests and produces all errors into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found