Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test file found by "testMatch" but somehow nothing found in "Pattern" #511

Closed
nam-truong-le opened this issue Feb 15, 2020 · 5 comments
Closed
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency

Comments

@nam-truong-le
Copy link

Current Behavior

I create a brand new project by running "npx tsdx create" and run "npm test" but no test file is found, see screenshot:

2020-02-15_13-36-52

We can see that one test file was found at the beginning:

testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 1 match

Expected behavior

Test file should be found.

Suggested solution(s)

Additional context

Your environment

Software Version(s)
TSDX 0.12.3
TypeScript 3.7.5
Browser
npm/Yarn npm 6.13.7
Node v12.1.0
Operating System OSX 10.15.3
@agilgur5
Copy link
Collaborator

agilgur5 commented Feb 15, 2020

Literally got this same issue in one of my projects yesterday, agilgur5/jest-without-globals#2 (comment) . Was extremely confusing and time-consuming.

Per that issue, it's happening because the internal --config arg is being sliced off for some reason and so the config is being passed as a pattern instead. Was very confused by the output for a while

I haven't been able to reproduce it everywhere (despite all using v0.12.3), so I have a feeling this is a bug in the CLI dependency, sade. Seems like it just had some patches released, so I'm guessing newer TSDX installations grabbed the recent patch while older ones have it locked to a lower version.

Will investigate further -- in the meantime might be able to fix this with a Yarn resolution to sade v1.7.0 or below.

@agilgur5
Copy link
Collaborator

Oh also another workaround is to pass literally any argument to tsdx test and it'll be sliced off instead of --config.

This also means to get coverage right now you have to do e.g. tsdx test --sliceme --coverage.

A Yarn resolution would be better though.

It might impact other commands too, but not sure as the args are treated differently in test due to Jest's non-existent programmatic API

@agilgur5
Copy link
Collaborator

agilgur5 commented Feb 15, 2020

Confirmed that this does not occur on sade v1.7.0. It was introduced in sade v1.7.1 (released 3 days ago) due to using a mutative splice call on process.argv in 2 places, see diff here: lukeed/sade@4ccffe0#diff-6d186b954a58d5bb740f73d84fe39073R129

It shouldn't mutate process.argv -- I'm writing up a PR to sade to get that fixed ASAP

@agilgur5
Copy link
Collaborator

Sent a PR upstream: lukeed/sade#36

Hopefully the root cause is resolved upstream soon.

TSDX could pin sade@1.7.0 as well as a stop-gap, but Jared is behind on releases and merges and that would only solve the bug for those who upgraded TSDX to latest, all older versions would get this bug if it's not patched upstream.

@agilgur5
Copy link
Collaborator

agilgur5 commented Feb 27, 2020

Just updating here that lukeed/sade#36 was merged within ~10 hours of me making it and was released in sade@1.7.3 .

Because the bug was upstream, no updates to TSDX itself are necessary. To get this fix in tsdx you just need re-install (npm i tsdx). The 1.7.2 -> 1.7.3 bump will be in your package-lock.json (or yarn.lock). All new installs will have the latest version of sade by default.

This issue can be closed as it's been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency
Projects
None yet
Development

No branches or pull requests

2 participants