-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support extension settings ('pretest', 'packageManager', 'testCommand', 'extraArguments', and 'executableOptions') #11
Conversation
…', 'extraArguments', and 'executableOptions')
Hey @rluvaton. Wondering if you had the chance to see this PR. We would love to use this extension with these changes |
Hey, sorry, looking now thanks for the contributions |
package.json
Outdated
"vscode-vitest.executableOptions": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"default": ["run", "debug", "watch"], | ||
"description": "Choose which executable options to enable" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value should not be anything other than run, debug and watch, please change the items type to be enum instead of string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I think we should the package manager option and instead have that in so the default value will be |
src/run.ts
Outdated
terminal = vscode.window.createTerminal(`vscode-vitest-runner`); | ||
} | ||
const pretest = (config.get("pretest") as string[]); | ||
const finalPretest = pretest.length > 0 ? [`${pretest.join("; ")};`] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- having
;
would not fail if pretest command fail please replace to&&
- How other test runner extensions do this, this seems like can be security problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Done
- The way jest runner does it is to simply change the jest command. So, regarding the security issue, I guess it's fine since they also allow you to that whatever and it's a pretty popular extension (1.000.000+ downloads) 🤷
This is what I currently have in mine (I'm using jest runner in the meanwhile while my changes take effect in this repo)
If I'm not answering don't hesitate and reach out on Twitter ( |
@rluvaton I initally tried to do this, just like jest test runner does, but this line stopped me from doing it https://github.com/cafesanu/vitest-vs-code-plugin/blob/chore/support-settings/src/run.ts#L84 as it only needs the package manager, so I opted to separate it into two settings so I didn't have to refactor the whole thing |
@rluvaton Lastly, I added a |
@rluvaton sorry to keep bothering. Any chance you can review the requested changes. Would love to have these changes. Thanks! |
Will get to it today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to use pre and post scripts? I prefer to avoid due to security reasons
Co-authored-by: Raz Luvaton <16746759+rluvaton@users.noreply.github.com>
Hey @rluvaton thanks for your review. My argument is that the most popular runner, jest runner, already lets you do this. In our case, we must run translations before we run unit test, and have to clean them after. My whole reason for creating this PR is that we need these steps. But I totally understand your concern and don't want to force anything here. I would have to fork this extension and create another extension and publish it. Happy to do that if you feel uncomfortable with these changes |
I'll test it manually tomorrow night and if everything ok I'll merge it, thank you for your patience |
You had a small bug, fixed it and merging now, thank you! |
Published! |
Hey @rluvaton. First, thanks for this extension! Truly the only one that worked for us.
Though I would help by adding extension settings.
"run"
or"watch"
string, I merged them into one and now the string"run"
or"watch"
can be passed to the function.Extension Settings
vscode-vitest.preTest
["npm run script1", "npm run script2"
(will run in the given order. If command(s) fail, tests will not run)vscode-vitest.postTest
["npm run clean1", "npm run clean2"
(will run in the given order)vscode-vitest.packageManager
npm
,yarn
,pnpm
,pnpn dlx
, etcnpx
vscode-vitest.testCommand
test
(e.g. for CRA, package.jsontest
script, or similar abstractions)vitest
vscode-vitest.extraArguments
--silent=true --maxWorkers=2
""
vscode-vitest.executableOptions
{"debug": false, "run": false}
(will only displaywatch
){"debug": true,"run": true, "run": true}
Example Settings: