-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(config): allow percentage value for workers option #5982
feat(config): allow percentage value for workers option #5982
Conversation
0663b6c
to
7a35516
Compare
585ad06
to
6cdf19d
Compare
I want to add test for worker option but I found two problems.
I don't think I can test the code properly if I can't mock |
You can create a separate utility that accepts the workers number and the amount of CPU and test that function. |
6cdf19d
to
f643a52
Compare
Thanks for nice idea! I separate getWorkers function to utility and node:os mock is works. I added test now. |
}) | ||
|
||
describe('workers util', () => { | ||
vi.mock('node:os', async importOriginal => ({ |
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.
vi.mock
is always hoisted to the top of the file so it doesn't make a sense to have it inside describe
function, let's put it at the top to make it less confusing. You can also use import
syntac so you don't need to case the Record
type:
vi.mock('node:os', async importOriginal => ({ | |
vi.mock(import('node:os'), async importOriginal => ({ |
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.
Now that I look at it, I wonder how vi.mock
worked. It's all reflected. thank you!
b81b684
to
47bd7af
Compare
47bd7af
to
1615b56
Compare
test failed.. because maybe i changed node:os import method. I fix test in a minutes. |
c642034
to
e8e52ee
Compare
Description
I can't use maxWorkers option that jest supported after migrating to vitest.
So I modified it so that the percentage value can be used in maxworkers and minworkers.
jestjs/jest#9012 (comment)
Although it is a feature request in jest, I would like to get the same feature in viteest.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.