briebug/jest-schematic

Issue with Angular 8: `src/tsconfig.spec.json` => `tsconfig.spec.json`

yjaaidi opened this issue ยท 7 comments

Describe the bug
Using the schematic with Angular 8 then running the tests will produce the following error:

 File not found: <rootDir>/src/tsconfig.spec.json (resolved as: /.../src/tsconfig.spec.json)

This is due to the fact that Angular 8 moves tsconfig.spec.json out of src while jest-angular-preset is expecting tsconfig.spec.json to be in src.

Maybe jest-angular-preset should automatically detect tsconfig.spec.json location but it might be easier to handle this in this schematic as a temporary fix.

Meanwhile, there are two workarounds (and maybe more):

  1. ๐Ÿ˜”Move tsconfig.spec.json back to src.
  2. โœ…Update jest.config.js:
const tsJestPreset = require('jest-preset-angular/jest-preset').globals['ts-jest'];

module.exports = {
  ...
  globals: {
    'ts-jest': {
      ...tsJestPreset,
      tsConfig: 'tsconfig.spec.json'
    }
  }
};

To Reproduce
Steps to reproduce the behavior:

  1. npm install -g @angular/cli@8.0.0
  2. ng add @briebug/jest-schematic
  3. npm test
  4. See error

Thanks for putting this through an early Angular 8 test and for investigating the issue and resolutions.

Thank you for the schematic ๐Ÿ˜Š

@yjaaidi I took a look into it and I think it's an issue in jest-preset-angular

I just opened the issue on jest-preset-angular too thymikee/jest-preset-angular#286

Also getting this same issue in an angular 8 project.

Also getting this same issue in an angular 8 project. +1

+1 On Ng7