briebug / jest-schematic

Angular schematic for adding Jest and the required files to an Angular CLI project
MIT License
322 stars 38 forks source link

Librarys with deeper entrypoints: An unhandled exception occurred: Cannot find module '../../jest.config' #112

Open andreElrico opened 2 years ago

andreElrico commented 2 years ago

Describe the bug Seems not to work if we have a nested library. Could fix it easily by changing the import path inside my library, in file jest-config.js

from
const baseConfig = require('../../jest.config');
to
const baseConfig = require('../../../jest.config');

To Reproduce

  1. have a library with name myComp/myFirstLibrary.
  2. run schematics
  3. run ng test
  4. look at error:
An unhandled exception occurred: Cannot find module '../../jest.config'
Require stack:
- C:\Users\xxxxxxxx\yyyyy\zzzz\projects\myComp\myFirstLibrary\jest.config.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-builders\jest\dist\custom-config.resolver.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-builders\jest\dist\index.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular\cli\models\architect-command.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular\cli\commands\test-impl.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular\cli\models\command-runner.js
- C:\Users\xxxxxxxx\yyyyy\zzzz\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\xxxxxxxx\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
See "C:\Users\xxxxxxxx\AppData\Local\Temp\ng-MsP1Ng\angular-errors.log" for further details.

Expected behavior The schematics could realize the folder depth and set the correct import.

Additional context

    "@briebug/jest": {
      "version": "1.3.1",

    "@briebug/jest-schematic": {
      "version": "4.0.0",