Simple approach to run just the tests you need when building for the CLI #1882
-
Hello team! I was wondering what was you approach to run just the tests you needs when you are building for the CLI. Not that it's "super" long to build than to run the entire test suite, but just to find your command, look at how it goes... It can sometimes overwhelming and I wanted to find a better option. Let me know if you see any other brilliant option! I tried to look at the mocha extensions for vscode and none of them really worked for what I was looking for without adding dependencies to the project and I did not want to do that. So I decided to go the more "custom" way. So I did the following :
It's now giving me this, and I'm pretty happy with it! I can continuously validate my tests while I add capabilities to the commands I'm working on. Do you see any drawbacks? With this, I'm not able to run the code coverage as it only runs it on the command you are watching, meaning that all the references are only partially covered in your command. Or is there a way better approach (maybe even already in the CLI) I was not able to find? Thoughts? What is YOUR go-to for this kind of productive debugging? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I'm going about it in two ways:
Like you noticed, neither approach is useful for the coverage but helpful when building tests. |
Beta Was this translation helpful? Give feedback.
I'm going about it in two ways:
package.json
, I'm adding a new script that matches only the specific test file, eg."test:dev": "c8 mocha \"dist/**/Utils.spec.js\""
. That way I can have mocha run just these tests, which is pretty fast. One thing you need to keep in mind is that you should remember to remove this script before committing your changes.only
either to the whole suite (describe
statement) or a single test (it
), eg.describe.only(....
. That way mocha will run only this one suite/test. You can add.only
to one or multiple tests/suites. One drawback is, that without modifying the test script, mocha will still parse all matching files, but will just run tests flag…