-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(testing): support vite configOverrides for cypress #26554
feat(testing): support vite configOverrides for cypress #26554
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 1bfecfe. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 5 targets
Sent with 💌 from NxCloud. |
70cdb77
to
359b4dd
Compare
@jaysoo @ndcunningham @Coly010 @isaacplmann Could someone from nx review this PR? Because we would like to make use of this feature 😃 |
@AgentEnder @mandarini @FrozenPandaz @Cammisuli @jdpearce @xiongemi @MaxKless It would be great if someone could please review this rather small change, we could really make use of it 😀 |
f81e18c
to
1bfecfe
Compare
@@ -40,7 +40,9 @@ const cache = new Map<string, string>(); | |||
* This preprocessor shouldn't be used directly. | |||
* Instead, use the nxE2EPreset(__filename, { bundler: 'vite' }) function instead. | |||
*/ | |||
function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { | |||
function vitePreprocessor( | |||
configOverrides: InlineConfig = {} |
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.
Usages of vitePreprocessor('/path/to/vite.config.ts')
will break right? Do we need to overload the function or deprecate something?
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.
Nevermind, it's an internal API. :)
Thanks for merging 😊 |
We'd like to use shared cypress commands, but that's currently not working because vite cannot resolve the import. By allowing to pass options to the vite config we have the possibility to add an alias or a plugin to fix this. This adds support for an **optional** `viteConfigOverrides` object. ## Current Behavior ![Screenshot 2024-06-14 at 15 19 21](https://github.com/nrwl/nx/assets/951290/78f5037f-c839-4227-a3ea-4de4142006cf) cypress.config.ts: ```ts import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; import { defineConfig } from 'cypress'; export default defineConfig({ e2e: { ...nxE2EPreset(__filename, { cypressDir: 'cypress', bundler: 'vite' }), }, }); ``` ## Expected Behavior ![Screenshot 2024-06-14 at 15 23 56](https://github.com/nrwl/nx/assets/951290/385cde67-91b9-462e-9bfa-0c784d3947b7) cypress.config.ts: ```ts import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; import { defineConfig } from 'cypress'; const viteConfigOverrides = { resolve: { alias: { '@cypress-shared-commands': '../../../shared-cypress-commands', }, }, }; export default defineConfig({ e2e: { ...nxE2EPreset(__filename, { cypressDir: 'cypress', bundler: 'vite', viteConfigOverrides }), }, }); ``` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # (cherry picked from commit 764ecee)
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
We'd like to use shared cypress commands, but that's currently not working because vite cannot resolve the import.
By allowing to pass options to the vite config we have the possibility to add an alias or a plugin to fix this.
This adds support for an optional
viteConfigOverrides
object.Current Behavior
cypress.config.ts:
Expected Behavior
cypress.config.ts:
Related Issue(s)
Fixes #