Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Components that import modules with path aliases fail to mount#31029

Unanswered
rodneyallanprice asked this question inComponent Testing
Discussion options

We are using Nuxt 3.15.2 with Vite and Vue. Nuxt/Vite configures path aliases for '@' and '~' that work fine when run normally. Those aliases are not recognized when mounting a component with Cypress.

Screenshot 2025-02-05 at 2 29 49 PM

An answer to a question previously posted on this site suggested removing 'viteConfig' from the component section of the cypress config file and configuring the needed aliases in one of several vite config files as follows.

const vue = require('@vitejs/plugin-vue')import path from 'path'module.exports = {  plugins: [    vue()  ],  resolve: {    alias: {      '@/': `${path.resolve(__dirname, 'src')}/`,      '~/': `${path.resolve(__dirname, 'src')}/`    }  }}

Outside of the Nuxt environment, this works.

However, Nuxt wants to own vite configuration, and complains when I create one of the vite config files suggested by Cypress.

When using Nuxt to configure Vite, is there a way to tell Cypress component tests how to translate the aliases?

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@rodneyallanprice

[8]ページ先頭

©2009-2025 Movatter.jp