Run nested inline projects
Clear and concise description of the problem
Let's say the root config is projects: ['packages/*'] and each package configure several inline projects to run unit tests or e2e tests, for example.
In CI, you may want to run e2e tests using the docker image provided playwright along with vitest --run --project='*:e2e'. And run the non e2e tests on the node image.
Currently, projects do not run nested projects.
In #8273, @sheremet-va made a case against running nested project through reference, but I think the case of inline projects holds.
Suggested solution
Have vitest run nested inline projects
Alternative
No response
Additional context
No response
Validations
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
yeah this is very much needed I think. Currently it seems like if I have one package in the monorepo that needs to define 2 or more projects, the only solution is to disable the root project feature, and instead run vitest on every package individually, and merge results / coverage etc manually :(
This is planned as 4.1 feature.
It would be nice if for each package project when ran at the root the project name would be derived from the package.json + config name. For example the example here https://vitest.dev/guide/projects.html#configuration
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
test: {
pool: 'threads',
projects: [
{
// will inherit options from this config like plugins and pool
extends: true,
test: {
name: 'unit',
include: ['**/*.unit.test.ts'],
},
},
{
// won't inherit any options from this config
// this is the default behaviour
extends: false,
test: {
name: 'integration',
include: ['**/*.integration.test.ts'],
},
},
],
},
})
When running this from the root the name would use be @package/name/unit so if you have multiple packages with both the same projects it will work from the root.