Open tillig opened 11 months ago
This is a reasonable idea, it could be something like
jest.config.js|ts|mjs|cjs|json
exists in a parent directory, ORjestrunner.*
is set?We need to account for monorepo structures where the jest config file is not always in the ancestory of the current file.
It would probably be good to do some sort of detection of whether Jest is even installed/referenced
Checking if jest is installed is a bit tricky, some configurations use global jest. There is also npm workspaces to consider 🤔
Open to ideas on this one.
For a workaround (not really a "fix"), you can disable the extension for your single workspace:
If I'm not mistaken, the monorepo situation would still be covered by "If any settings jestrunner.*
is set" - if the config isn't in the file ancestry, it'd have to be provided to the extension somehow, which would mean the test command would need to be configured or the config location would need to be configured.
I suppose there's technically "run without any config" too. I'm not sure what to do about that.
But, yes, the workaround is to disable the extension, which I did.
I have a repository that uses Mocha for testing (so there's a
.mocharc.json
in the root andmocha
is referenced inpackage.json
). I also have both this extension and Mocha Test Explorer installed.Mocha Test Explorer adds
Run
andDebug
options over each test just like the Jest runner does:The challenge is that if I pick the wrong "Run" then it tries to run the tests using Jest... but Jest isn't installed or referenced here.
It would probably be good to do some sort of detection of whether Jest is even installed/referenced before showing the option to run/debug tests; otherwise it competes with other extensions and gets confusing.