Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TimvdEijnden
Copy link

@TimvdEijnden TimvdEijnden commented Jun 14, 2024

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

cypress.config.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

cypress.config.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)

Fixes #

@TimvdEijnden TimvdEijnden requested a review from a team as a code owner June 14, 2024 13:26
Copy link

vercel bot commented Jun 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jun 17, 2024 7:24am

@TimvdEijnden TimvdEijnden force-pushed the feat/cypress-viteconfig-overrides branch from 70cdb77 to 359b4dd Compare June 14, 2024 14:13
@TimvdEijnden
Copy link
Author

TimvdEijnden commented Jun 20, 2024

@jaysoo @ndcunningham @Coly010 @isaacplmann Could someone from nx review this PR? Because we would like to make use of this feature 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant