hbenl / vscode-test-explorer

The VS Code Test Explorer extension
MIT License
215 stars 55 forks source link

How to register a pretest command? #196

Closed GP4cK closed 3 years ago

GP4cK commented 3 years ago

I have a NodeJS project with a pretest command which sets up a docker container with a postgres database. Most of my tests are then populating the db inside a beforeAll, then running some logic, then clearing the db with an afterAll.

When I run npm test, the pretest command is automatically run by npm / node. Is there a way to setup a pre-job when using this extension?

AlexHaxe commented 3 years ago

try setting haxeTestExplorer.testCommand - you can put something like ["npm", "test"] in there then you want to make sure that your compilation step includes a -lib test-adapter so it gets compiled into your "binary" - required to make results show up in test explorer view

note: compilation should happen from project root otherwise .unittest folder might end up where it won't be picked up by test adapter

GP4cK commented 3 years ago

Sorry I'm confused. The config you proposed is for this package, right? I'm only using this one... If I write "haxeTestExplorer" or "haxeTestExplorer.testCommand" in my .vscode/settings.json, VSCode tells me "unknown configuration setting".

Actually, I can just call npm run pretest before launching the tests with the test explorer. But I would still need an option to run the tests in band / one after another rather than concurrently.

AlexHaxe commented 3 years ago

Ohh wow, I'm the one being confused... I thought your issue was posted over at Haxe's test adapter repository. I didn't realise we were in the main test explorer UI repository. sorry, my bad. disregard my steps to solve your issue.

anyway you might want to look at what actual test adapter you are using and see if it has a way to do what you need.

GP4cK commented 3 years ago

@AlexHaxe you're right, better create another issue over there. Thanks https://github.com/kavod-io/vscode-jest-test-adapter/issues/118