Closed PurpleBooth closed 3 years ago
Possibly same as #908?
"test": "tsdx test --no-cache",
It was definately the caching. This fixed it. So this makes it a dupe of the above. Closing.
Yea TSDX does not read node_modules
by default. TSDX does not specify a testPathIgnorePatterns
in its default config, meaning it uses Jest's default, which is "/node_modules/"
. So by default anything in node_modules
is ignored.
TSDX also dogfoods tsdx test
and this issue does not occur in internal tests or in CI runs.
You may have misread the test output too, because it doesn't show it reading a file from node_modules
:
FAIL test/reader.test.ts
It does show the output for that file to be from a different file though, which, yes does sound like an upstream cache issue.
test/blah.test.ts:1:10 - error TS2305: Module '"../src"' has no exported member 'sum'.
Specifically, that output is not from Jest, but from ts-jest
's diagnostics / type-checking. It's worthwhile to note that this can be turned off per https://github.com/formium/tsdx/issues/681#issuecomment-612929386. You can also turn off ts-jest
itself (and just use babel-jest
) for testing as some users do.
Possibly same as #908? So this makes it a dupe of the above.
TypeError
inside of ts-jest
itself, this is a stale cache. So they're not duplicates.But in any case, this issue is upstream in ts-jest
and not in TSDX, so I would recommend searching there for similar errors and filing an issue there. We don't have any control over cache issues with ts-jest
and I can't reproduce this (cache errors are quite difficult to repro as they are stateful).
Thanks for the detailed response. I disabled caching for ts-jest, the problem has vanished.
Current Behavior
Jest runs tests in the node_modules directory (maybe), or it's somehow caching old ts files somewhere?
Expected behavior
Tests not to be run in the node_modules directory
Suggested solution(s)
I'm not actually sure what's causing this, so it's hard to say. The jest config looks ok to me
Additional context
This is a pretty new project, so it's not customised. I also had a play with manually adding node_modules to the file ignore list in the jest config, just to check that the default was working as expected, and that didn't seem to make a difference.
Your environment