Dynamic-scoped workspace for changed components on CI and config reuse #6038
Unanswered
501NotImplemented
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Can't you just use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. I am looking for some best practices/ideas on how to define the scope for running the Vitest tests for a changed components in PR on the CI level.
As of now, I have the following structure:
I have a root vitest config, a workspace file with two projects, where I dynamically populate the include property, based on the changed components in the feature branch.
The tests, that I want to run are using Vitest and React Testing Library. The components are located in Lib/CustomComponents directory and each of the components has it's own vitest.config.ts file, where the output file is customized. Each of the components vitest.config.ts file is referencing the shared config, located in Lib/CustomConfigs.
Each component has the setupTests.ts file, where the JSDom is referenced and/or mocked.
e.g.
These setup files are called from the components vitest.config.js and are defined in a setupFiles property
When running the tests for the specific component from it's terminal - everything works as expected, the setup files are taken into account, the configs are resolved and tests are green.
But when I run the tests for the changed projects by calling vitest --project=changedComponents, the tests are failing because jest-dom assertions are not resolved, since setup files are not executed. I assume that components vitest.config.ts files are ignored.
Error: Invalid Chai property: toHaveClass
Any ideas how to merge the custom component's configs with the dynamic workspace configuration?
The thing is I'm not restricted to using the workspace, but I thought it would be more convenient and clear way to execute the tests.
Is it possible to dynamically form the include flag and pass it as a CLI argument to vitest, so the component's configs and executable environment would be used? e.g.
Beta Was this translation helpful? Give feedback.
All reactions