Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions npm/vite-dev-server/client/initCypressTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ if (supportFile) {
})
}

// Using relative path wouldn't allow to load tests outside Vite project root folder
// So we use the "@fs" bit to load the test file using its absolute path
const testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs${CypressInstance.spec.absolute}`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like @fs is a Vite thing - I couldn't find much documentation outside of https://vitejs.dev/config/server-options.html#server-fs-allow.

I'll update the snapshots - I don't know if this breaks anything, but I always thought the src/src duplication was kind of weird.

/* Spec file import logic */
// We need a slash before /src/my-spec.js, this does not happen by default.
importsToLoad.push({
load: () => import(`${devServerPublicPathRoute}/${CypressInstance.spec.relative}`),
load: () => import(testFileAbsolutePathRoute),
absolute: CypressInstance.spec.absolute,
relative: CypressInstance.spec.relative,
relativeUrl: `${devServerPublicPathRoute}/${CypressInstance.spec.relative}`,
relativeUrl: testFileAbsolutePathRoute,
})

if (!CypressInstance) {
Expand Down
8 changes: 4 additions & 4 deletions system-tests/__snapshots__/vite_dev_server_fresh_spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports['@cypress/vite-dev-server react executes all of the tests for vite4.0.4-
1) An uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.

> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/src/AppCompilationError.cy.jsx
> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/@fs/foo/bar/.projects/vite4.0.4-react/src/AppCompilationError.cy.jsx

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Expand Down Expand Up @@ -499,7 +499,7 @@ exports['@cypress/vite-dev-server react executes all of the tests for vite2.8.6-
1) An uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.

> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/src/AppCompilationError.cy.jsx
> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/@fs/foo/bar/.projects/vite2.8.6-react/src/AppCompilationError.cy.jsx

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Expand Down Expand Up @@ -938,7 +938,7 @@ exports['@cypress/vite-dev-server react executes all of the tests for vite2.9.1-
1) An uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.

> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/src/AppCompilationError.cy.jsx
> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/@fs/foo/bar/.projects/vite2.9.1-react/src/AppCompilationError.cy.jsx

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Expand Down Expand Up @@ -1377,7 +1377,7 @@ exports['@cypress/vite-dev-server react executes all of the tests for vite3.0.2-
1) An uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.

> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/src/AppCompilationError.cy.jsx
> Failed to fetch dynamically imported module: http://localhost:xxxx/__cypress/src/@fs/foo/bar/.projects/vite3.0.2-react/src/AppCompilationError.cy.jsx

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Expand Down