just-jeb / jest-marbles

Helpers library for marbles testing with Jest
MIT License
112 stars 13 forks source link

Unit tests fail with 'TS2307: Cannot find module 'jest-marbles' or its corresponding type declarations' in Azure DevOps pipelines #541

Open cliffAtOsaic opened 1 month ago

cliffAtOsaic commented 1 month ago

I'm aware this could be an Azure DevOps issue or some configuration issue on my part rather than a bug. Any help is appreciated.

Working on a private branch of our Node web app code with a freshly installed copy of jest-marbles 3.1.0.

Running from the command line locally works fine, effectivly:

npm ci
nx exec -- nx build --skip-nx-cache
npx nx test --coverage --coverageReporters=cobertura,lcov

Executed locally, these steps work fine and 100% test pass rate.

However, in Azure DevOps, 7 tests fail with the error:

TS2307: Cannot find module 'jest-marbles' or its corresponding type declarations

I haven't been able to find the discrepancy between the build pipeline and the local environment. Any suggestions?

just-jeb commented 1 month ago

Not sure how I can help here honestly.
The error seems to be coming from TS, but it complains about non-existent module. I'd try to isolate it: try to run the same pipeline with JS test (to see if the issue is the module or TS), and if it reproduces in JS then try to debug it with why yarn, print out the lock file, node_modules structure and understand why the module is not there. It might be just some Yarn/NPM hierarchy issue (especially if it's a monorepo) but maybe also something else.