nx icon indicating copy to clipboard operation
nx copied to clipboard

Jest module doesn't show all error logs after run

Open Tom910 opened this issue 2 years ago • 0 comments

Current Behavior

NX doesn't have any additional logs, just a status

npm run test

> @org/[email protected] test
> nx test


> nx run org:test

● Validation Warning:

  Unknown option "coverageDirectory" with value "./coverage/org" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration


 RUNS   org  src/app/app.spec.ts

 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target test for project org (2s)

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Expected Behavior

In sometimes run just a jest command provide additional logs

npm run test

> [email protected] test
> jest

 PASS  ./test.test.js
  DbJsonFileHandler tests
    ✓ test 1 (1 ms)
    ✓ test 2 (1 ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.198 s
Ran all test suites.
Error: ENOENT: no such file or directory, open '/private/var/folders/9n/k1w88pqn65q7dc6h71_k5k840000gn/T/jest_dx/perf-cache-e705b5a22e3a78c410225264a8a665b5-da39a3ee5e6b4b0d3255bfef95601890'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at /Users/amarchenko/Downloads/test/node_modules/@jest/test-sequencer/build/index.js:276:12
    at Map.forEach (<anonymous>)
    at TestSequencer.cacheResults (/Users/amarchenko/Downloads/test/node_modules/@jest/test-sequencer/build/index.js:275:17)
    at runJest (/Users/amarchenko/Downloads/test/node_modules/@jest/core/build/runJest.js:370:13)
    at _run10000 (/Users/amarchenko/Downloads/test/node_modules/@jest/core/build/cli/index.js:344:7)
    at runCLI (/Users/amarchenko/Downloads/test/node_modules/@jest/core/build/cli/index.js:199:3)
    at Object.run (/Users/amarchenko/Downloads/test/node_modules/jest-cli/build/run.js:124:37)
node:fs:2533
      handleErrorFromBinding(ctx);
      ^

Error: ENOENT: no such file or directory, lstat '/Users/amarchenko/Downloads/test/node_modules/exit'
    at Object.realpathSync (node:fs:2533:7)
    at toRealPath (node:internal/modules/cjs/loader:466:13)
    at tryFile (node:internal/modules/cjs/loader:462:10)
    at tryExtensions (node:internal/modules/cjs/loader:474:22)
    at tryPackage (node:internal/modules/cjs/loader:419:5)
    at Function.Module._findPath (node:internal/modules/cjs/loader:638:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1012:27)
    at Function.Module._load (node:internal/modules/cjs/loader:871:27)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at _exit (/Users/amarchenko/Downloads/test/node_modules/jest-cli/build/run.js:23:39)
    at Object.run (/Users/amarchenko/Downloads/test/node_modules/jest-cli/build/run.js:134:9) {
  syscall: 'lstat',
  code: 'ENOENT',
  errno: -2,
  path: '/Users/amarchenko/Downloads/test/node_modules/exit'
}

GitHub Repo

No response

Steps to Reproduce

  1. Set Up a project by using npx create-nx-workspace@latest
  2. Install a dependency npm i --save-dev mock-fs
  3. Change a code of file src/app/app.spec.ts on
const mock = require('mock-fs');

describe('DbJsonFileHandler tests', () => {
  test('test 1', async () => {
    mock({
      './': {}, // Empty current directory
      '/etc/bookings/': {},
    });
    expect(true).toBe(true);
  });
  test('test 2', async () => {
    mock({
      './': {}, // Empty current directory
      '/etc/bookings/': {},
    });
    expect(true).toBe(true);
  });
});
  1. Run tests npm run test

Nx Report

nx report

 >  NX   Its time to update Nx 🎉

   Your repository uses a higher version of Nx (16.3.2) than your global CLI version (15.9.4)
   For more information, see https://nx.dev/more-concepts/global-nx


 >  NX   Report complete - copy this into the issue template

   Node   : 16.20.0
   OS     : darwin arm64
   npm    : 8.19.4
   Hasher : Native

   nx (global)        : 15.9.4
   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/devkit         : 16.3.2
   @nx/esbuild        : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nx/node           : 16.3.2
   @nrwl/tao          : 16.3.2
   typescript         : 5.0.4

Failure Logs

No response

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

No response

Tom910 avatar Jun 16 '23 16:06 Tom910