feat(nx-plugin): add vitest support for e2e tests#34041
feat(nx-plugin): add vitest support for e2e tests#34041
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 4c65167
☁️ Nx Cloud last updated this comment at |
| addProjectConfiguration(host, options.projectName, projectConfiguration); | ||
| } | ||
|
|
||
| const vitestTask = await vitestConfigurationGenerator(host, { |
There was a problem hiding this comment.
@copilot This call should use ensurePackage, as vitest may not be installed yet. We can't directly import this, though we can import it's types so we can reference them in the dynamic import.
coverageProvider should likely be null, since its e2e we wouldn't really collect coverage.
There was a problem hiding this comment.
Updated to use ensurePackage for dynamic import of @nx/vitest and removed explicit coverageProvider since it will use the default. Changes in commit bcce4fe.
| expect(vitestConfig).toContain('globalSetup'); | ||
| expect(vitestConfig).toContain('globalTeardown'); |
There was a problem hiding this comment.
Lets add an e2e test to e2e/plugin that tests that these work for vitest backed plugins, I'm a bit hesitant without it. @copilot
There was a problem hiding this comment.
Added e2e test in e2e/plugin/src/nx-plugin.test.ts that verifies plugins can be generated with vitest as the e2e test runner and that the tests execute successfully. Commit 6add8ac.
@copilot this is close, but it should be an optional peer dep |
Added |
37cacee to
6bf85d6
Compare
- Initialize vitestConfigPath with undefined to avoid uninitialized variable - Add explicit error handling when vitest config file is not found - Add comment explaining mts extension precedence - Store regex in variable for better readability Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
- Extract indentation from existing config for consistent formatting - Add better error handling for test config block not found - Remove redundant undefined initialization - Insert globalSetup/globalTeardown as separate lines to avoid overwriting existing properties Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
…eProvider - Use ensurePackage to dynamically import @nx/vitest since it may not be installed yet - Import VitestGeneratorSchema type for type safety - Remove explicit coverageProvider since e2e tests don't need coverage collection Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Co-authored-by: Copilot <Copilot@users.noreply.github.com>
Add end-to-end test to verify that plugins can be generated with vitest as the e2e test runner and that the e2e tests execute successfully. Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Co-authored-by: Copilot <Copilot@users.noreply.github.com>
Add @nx/vitest as an optional peer dependency instead of a regular dependency to properly declare the runtime dependency while keeping it optional for users who don't use vitest for e2e tests. Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
0492be6 to
7fe23b8
Compare
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
Note
We tried rerunning the flaky task 5 times, but the task is still failing. You can trigger a rerun manually, or investigate the task.
Trigger a rerun:
Or trigger a rerun manually by pushing an empty commit:
git commit --allow-empty -m "chore: trigger rerun"
git push
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
Implementation Plan for Vitest E2E Support
Changes Required:
addVitest()similar toaddJest()e2eProjectGeneratorInternalto conditionally call addJest or addVitestChanges
"vitest"toe2eTestRunnerenum in@nx/plugin:plugingenerator; addedtestRunneroption to@nx/plugin:e2e-projectgeneratoraddVitest()function that configures Vitest with globalSetup/globalTeardown for local registry management, uses fork pool with singleFork for proper isolation.mtsor.tsvitest config files, extracts existing indentation for consistent formatting when injecting global setup/teardownensurePackageto dynamically import@nx/vitestonly when needed; added as optional peer dependencyUsage
Jest remains the default when no testRunner is specified.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.