mammadataei / cypress-vite

Run Cypress specs using Vite
MIT License
85 stars 10 forks source link

Error importing material ui #87

Closed taran-ltc closed 5 months ago

taran-ltc commented 8 months ago

Hi. I am running cypress 2e2 tests and facing with error

Running: sign-in.cy.ts (1 of 1) node_modules/@mui/material/utils/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. node_modules/@mui/material/styles/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. node_modules/@mui/material/AccordionActions/AccordionActions.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. node_modules/@mui/material/AccordionDetails/AccordionDetails.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. node_modules/@mui/material/Accordion/Accordion.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. .... cypress.config.ts

import { defineConfig } from "cypress"; import vitePreprocessor from 'cypress-vite' import path from 'path'

export default defineConfig({
  e2e: {
    retries: 3,
    experimentalRunAllSpecs: true,
    setupNodeEvents(on) {
      on('file:preprocessor', vitePreprocessor({
        configFile: path.resolve(__dirname, './vite.config.ts'),
        mode: 'development'
      }),)
    }
  },
});

vite.config.ts

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import browserslistToEsbuild from 'browserslist-to-esbuild'

export default defineConfig({
    base: '',
    plugins: [react(), viteTsconfigPaths()],
    server: {
        open: true,
        port: 3000,
    },
    build: {
        target: browserslistToEsbuild([
            ">0.2%",
            "not dead",
            "not op_mini all"
        ]),
    },
})

sign-in.cy.ts `import { Alert } from '@mui/material'

describe('sign in', () => { beforeEach(() => { ...test that uses some from material UI ` Versions: "cypress": "^13.5.1", "cypress-vite": "^1.5.0", "vite": "^5.0.10", "vite-tsconfig-paths": "^4.2.2",

the error appears only when some material is imported

mammadataei commented 7 months ago

@taran-ltc Please try to run cypress-vite in debug mode; it might give us more information if something goes wrong during the compilation process.

github-actions[bot] commented 6 months ago

This issue is automatically marked as stale because it has been open for 30 days with no activity. Remove the stale label or leave a comment, or it will be closed in 14 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 14 days with no activity. Please feel free to open a new issue if you have any further questions.