nrwl / nx

Smart Monorepos Ā· Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

`jest.config.ts` doesn't get excluded from `tsconfig.lib.json` #10526

Closed theorlovsky closed 2 years ago

theorlovsky commented 2 years ago

Current Behavior

If you migrate to the Nx version where jest.config.ts was introduced, the migration will add those files to the exclude array in tsconfig.lib.json. However, when you generate a new lib after that, it gets generated without jest.config.ts being excluded from tsconfig.lib.json.

Expected Behavior

I expect some consistency here. jest.config.ts should either be excluded from tsconfig.lib.json or not, but not both.

Steps to Reproduce

  1. Create an Nx 13 workspace
  2. Create a lib with jest as a unit test runner
  3. Migrate to Nx 14
  4. Create another lib

Failure Logs

--

Environment

   Node : 16.15.0
   OS   : darwin x64
   npm  : 8.5.5

   nx : 14.1.9
   @nrwl/angular : 14.1.9
   @nrwl/cypress : 14.1.9
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.9
   @nrwl/eslint-plugin-nx : 14.1.9
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.9
   @nrwl/js : Not Found
   @nrwl/linter : 14.1.9
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.1.9
   @nrwl/web : Not Found
   @nrwl/workspace : 14.1.9
   typescript : 4.6.4
   ---------------------------------------
   Community plugins:
theorlovsky commented 2 years ago

any updates?

barbados-clemens commented 2 years ago

can you confirm this still happens in nx latest? I've not been able to reproduce this locally?

barbados-clemens commented 2 years ago

also what type of lib? this doesn't happen with angular/workspace/js/react libs from my testing

theorlovsky commented 2 years ago

@barbados-clemens yes, I can reproduce it on v14.5.2:

  1. npx create-nx-workspace --name jest-bug --appName jest-bug --preset=angular --nxCloud false --style scss
  2. cd jest-bug
  3. cat apps/jest-bug/tsconfig.app.json ā€“ no jest.config.ts in exclude
  4. npx nx g @nrwl/angular:library test
  5. cat libs/test/tsconfig.lib.json ā€“ no jest.config.ts in exclude as well
barbados-clemens commented 2 years ago

ah it looks like for ng projects it wasn't getting excluded. but is included in the .spec.json. Fixing it now. should have a PR up here soon. Odd it doesn't error out. Thanks for reporting šŸ˜„

barbados-clemens commented 2 years ago

Actually, could you send me the project's tsconfig, curious why it didn't get updated in the v14 migration as it should have excluded it for you.

theorlovsky commented 2 years ago

it is excluded in the existing projects, it was done by one of the migrations. but new projects keep creating without it being excluded

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.