Npx jest - Stencil unit tests are not matching any files

In my team, most are able to run ‘npx jest’ and tests execute normally, both on Windows and MacOS clients. I seem to have an unusual issue, and hope someone has run into this same issue and might be able to shed some light on the problem. I have confirmed that the installed OS libraries match, and the jest.config.js is committed to our repository and is the same for everyone.

I think this might be path related, I have tried removing the ‘./’ prefix in jest.config.js, but tests still don’t run.

Any assistance is appreciated.

Here is the console output on MacOS Monterey 12.6

MACHINE: product-stencil user$ npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/user/git/tmp/product-stencil
  3278 files checked.
  testMatch:  - 0 matches
  testPathIgnorePatterns: ./tmp, ./src/test, ./styleguide, ./src/main/custom/ts, ./src/main/custom/dist - 0 matches
  testRegex: (/__tests__/.*|\.?(test|spec))\.(ts|tsx|js|mjs|jsx)$ - 1030 matches
Pattern:  - 0 matches

Here is the jest.config.js,

const config = {
    preset: "@stencil/core/testing",
    testRunner: "jest-jasmine2",
    collectCoverage: true,
    coverageReporters: ["json", "html"],
    collectCoverageFrom: [
        "./src/main/custom/stencil/**/*.{ts,tsx}"
    ],
    coveragePathIgnorePatterns: [
        "./node_modules/",
        "./src/test/",
        "./styleguide/",
        "./src/main/custom/stencil/components.d.ts",
        "./src/main/custom/ts/",
        "./src/main/custom/dist/"
    ],
    testPathIgnorePatterns: [
        "./tmp",
        "./src/test",
        "./styleguide",
        "./src/main/custom/ts",
        "./src/main/custom/dist"
    ],
    coverageDirectory: "./target/jest-coverage",
    coverageThreshold: {
        global: {
            lines: 0
        }
    }
};
module.exports = config;

My team figured out a work around. We use nvm (node version manager) to switch the node version across different releases, so the issue was path related. This works in my situation:

To run one test:
/Users/user/.nvm/versions/node/v14.18.1/bin/node ./node_modules/.bin/stencil test --spec --max-workers=1 textarea-component.spec.ts

To run all tests (add the path to the files):
/Users/user/.nvm/versions/node/v14.18.1/bin/node ./node_modules/.bin/stencil test --spec --max-workers=1 src/main/custom/stencil/

Output:

[05:24.9]  @stencil/core
[05:25.1]  v2.19.3 🌏
[05:25.4]  testing spec files
[05:25.4]  jest args: --spec --max-workers 1 textarea-component.spec.ts
 PASS  src/main/custom/stencil/components/textarea/textarea-component.spec.ts
  Textarea Component 
    base component
      ✓ should have properties defined (26 ms)
      ✓ should call the configured onUpdate method (8 ms)
      ✓ should call the onUpdate on close-st event (6 ms)
      ✓ should emit the st_textarea_keydown on keydown event (4 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        0.742 s, estimated 1 s
Ran all test suites matching /textarea-component.spec.ts/i.