Skip to content

Module build failed in unit tests after saving code #12657

@IgorMinar

Description

@IgorMinar

(issue moved from angular/angular#26591)

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

Created a fresh angular 7 app and tried to execute unit tests. I works for the first run, but when I change something in the code and save, the unit tests are not executed.

Expected behavior

Unit tests should always be executed after saving.

Minimal reproduction of the problem with instructions

  1. Ensured current version of angular cli is globally installed npm install -g @angular-cli
  2. create a new app ng new bug-demo
    a. chose 'No' on the question if it should add angular routing
    b. selected 'SCSS' for styling language
  3. Run unit tests ng test
  4. As expected: Chrome opens and the three unit tests, which are generated by default are executed and successful.
  5. Make a change to src/app/app.component.ts, for example change the value of the title property
  6. save

Expected:
it should recompile, re-run the tests, and two of the tests should fail (if we changed the value of the title property)

Observed behaviour:

  • I see a short message that it's compiling on the console, but it disappears after a fraction of a second. There is no further activity on the console
  • On the Chrome tab, it just shows the header of Karma ("Karma v3.0.0 - connected" etc), below, it shows that there are 0 specs, 0 failures
  • When I go to the chrome console, I see the following error message:
Uncaught Error: Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: /home/paul.mattke/dev/bug-demo/src/app/app.component.spec.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (:9876/home/paul.mattke/dev/bug-demo/node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/angular_compiler_plugin.ts:1021)
    at plugin.done.then (:9876/home/paul.mattke/dev/bug-demo/node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/loader.ts:49)
    at <anonymous>
    at process._tickCallback (:9876/internal/process/next_tick.js:188)
    at AngularCompilerPlugin.getCompiledFile (:9876/home/paul.mattke/dev/bug-demo/node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/angular_compiler_plugin.ts:1021)
    at plugin.done.then (:9876/home/paul.mattke/dev/bug-demo/node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/loader.ts:49)
    at <anonymous>
    at process._tickCallback (:9876/internal/process/next_tick.js:188)
    at Object../src/app/app.component.spec.ts (VM77 main.js:252)
    at __webpack_require__ (VM77 main.js:79)
    at webpackContext (VM77 main.js:202)
    at Array.map (<anonymous>)
    at Module../src/test.ts (VM77 main.js:278)
    at __webpack_require__ (VM77 main.js:79)
    at checkDeferredModules (VM77 main.js:46)
    at VM77 main.js:152
    at VM77 main.js:155

What is the motivation / use case for changing the behavior?

With this bug, we can't test quite good any more, because we need to re-run ng-test after each change.

Environment


Angular version: 7.0.0

Browser:
- [x] Chrome (desktop) version 69.0.3497
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.11.1
- Platform:  Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions