Add @knapsack-pro/vitest#104
Conversation
c5cdff7 to
52eeab1
Compare
|
@BenLorantfy thank you for the PR. We have prioritized it and will review it soon. |
ArturT
left a comment
There was a problem hiding this comment.
I've added some comments.
Could you rename the PR title to: Add @knapsack-pro/vitest. There is a missing suffix: -pro.
You can also click on a request to run the workflow so that we can run the CircleCI build for this PR. I think this link should be somewhere in the Conversation tab in the right menu. docs I'd approve it then.
Thank you. Please let me know if I can help with anything.
|
|
||
| 2. Update your CI to use a matrix build. See the [example workflow](.github/workflows/vitest-example-test-suite.yaml) for reference. | ||
| 3. Replace `vitest` with `@knapsack-pro/vitest` in your CI config | ||
| 4. Set the `KNAPSACK_PRO_TEST_SUITE_TOKEN` environment variable to your Knapsack Pro test suite token, and optionally set other environemnt variables as needed. |
There was a problem hiding this comment.
Please could you use _VITEST suffix (KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST) so it's consistent with other test runners?
There was a problem hiding this comment.
Thanks for the review @ArturT 🙏
Do you mind if I push back a little bit on this comment? I agree it's consistent, but I find this approach a bit odd:
knapsack-pro-js/packages/jest/src/env-config.ts
Lines 3 to 6 in 1deb629
Generally I don't think it's recommended to set env variables like this during runtime. I asked v0 about this and it agreed: https://v0.dev/chat/fOuT0uzgMOL
Besides the general unexpectedness of this pattern, I also think it's a bit odd that only this env variable has a _VITEST suffix, and no other knapsack env variable has one.
So I would suggest this instead:
if (process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST) {
throw new Error("Please use KNAPSACK_PRO_TEST_SUITE_TOKEN instead of KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST");
}
That way if someone tries to use KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST, it will tell them to use KNAPSACK_PRO_TEST_SUITE_TOKEN. I hope that helps mitigate the lack of consistency, by helping consumers find the right env variable
What do you think?
There was a problem hiding this comment.
Do you mind if I push back a little bit on this comment? I agree it's consistent, but I find this approach a bit odd:
...
I agree with you. It's odd, and we don't like overriding the env var.
I'd like to break this into 2 separate steps.
For this PR, let's keep the old approach for consistency. Why it's important?
We would like to optimize for the end user's convenience. Some users run 2 different test runners on CI. They might run RSpec and Vitest. They use:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPECKNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST
The user can just add these to CI settings and that's it. For example, this is possible for CircleCI.
Otherwise, the user would add 2 env vars with unique names to the CI settings, then redefine them in the CI yml file to set KNAPSACK_PRO_TEST_SUITE_TOKEN. This requires extra work from the user. We would like the user experience to be smooth.
I think the long-term approach should be to change how the @knapsack-pro/core package works so that we don't need to redefine env var like this. But I'd like to keep it outside of the scope of this PR. We keep internal notes for that. Is that fine with you?
There was a problem hiding this comment.
Sure, sounds good 👍
|
We could also update the main README file to: diff --git a/README.md b/README.md
index 448744b..1db3de5 100644
--- a/README.md
+++ b/README.md
@@ -163,8 +163,10 @@ Read the READMEs inside the nested `packages/`:
- [core](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/core)
- [jest](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/jest)
+- [vitest](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/vitest)
- [cypress](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/cypress)
- [jest-example-test-suite](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/jest-example-test-suite)
+- [vitest-example-test-suite](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/vitest-example-test-suite)
- [cypress-example-test-suite](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/cypress-example-test-suite)
- [create-react-app-example](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/create-react-app-example)
|
|
I've been trying to run vitest tests locally. I've added a missing configuration for it on a separate branch: Feel free to cherry pick the following commit into this PR: I run tests locally this way: Everything seems to be working fine but after tests are completed then the process does not exit. It hangs. If I press enter then I'm getting this error: I think vitest starts in watch mode by default. The message |
|
Hi @ArturT , thanks for the review I think I've addressed or responded to all your comments.
Yes
I'm having trouble finding this option. Is it in github somewhere or it's in circleci?
|
| }, | ||
| "dependencies": { | ||
| "@knapsack-pro/core": "^7.1.0", | ||
| "@knapsack-pro/core": "^8.0.0", |
There was a problem hiding this comment.
Can we keep it as it was? I'd like to avoid coupling your PR with updating other clients. The same case is for the Jest client, which is down below.
There was a problem hiding this comment.
So I was running into an issue where working locally, @knapsack-pro/vitest wasn't using the version in the monorepo. npm was installing version 7.1.0, instead of linking to the monorepo version, since the version in the monorepo was 8.0.0
But sure I'll revert this
ArturT
left a comment
There was a problem hiding this comment.
@BenLorantfy Thank you for the improvements. I appreciate it.
I've managed to enable CircleCI for this PR. We have some linter errors:
https://app.circleci.com/pipelines/github/KnapsackPro/knapsack-pro-js/375/workflows/9d028f9b-5244-47f8-b1eb-dfb9da9db097/jobs/343
Would you be able to help resolve these errors? If you need any help with this or with any of my comments just let me know.
|
Let's also add |
|
thanks @ArturT , I think I've addressed all your comments. Please lmk if you have any other feedback |
ArturT
left a comment
There was a problem hiding this comment.
Awesome work! I'm happy that we will be able to help Vitest users. Thank you @BenLorantfy for your contribution.
I'll take care of releasing the package.
We will update our docs/dashboard in a separate step.


Adds
@knapsack/vitestpackageCloses #102
@knapsack-pro/PACKAGElabel