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

fix: supportFile path and supportFile false for vite on windows #21156

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 7 additions & 5 deletions npm/vite-dev-server/client/initCypressTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ const supportFile = CypressInstance.config('supportFile')
const projectRoot = CypressInstance.config('projectRoot')
const devServerPublicPathRoute = CypressInstance.config('devServerPublicPathRoute')

let supportRelativeToProjectRoot = supportFile.replace(projectRoot, '')
if (supportFile) {
let supportRelativeToProjectRoot = supportFile.replace(projectRoot, '')

if (CypressInstance.config('platform') === 'win32') {
supportRelativeToProjectRoot = supportFile.replace(projectRoot.replaceAll('/', '\\'))
}
if (CypressInstance.config('platform') === 'win32') {
const platformProjectRoot = projectRoot.replaceAll('/', '\\')

supportRelativeToProjectRoot = supportFile.replace(platformProjectRoot, '')
}

if (supportFile) {
// We need a slash before /cypress/supportFile.js, this happens by default
// with the current string replacement logic.
importsToLoad.push(() => import(`${devServerPublicPathRoute}${supportRelativeToProjectRoot}`))
Expand Down
11 changes: 11 additions & 0 deletions npm/vite-dev-server/cypress/e2e/vite-dev-server.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('Config options', () => {
it('supports supportFile = false', () => {
cy.scaffoldProject('vite2.9.1-react')
cy.openProject('vite2.9.1-react', ['--config-file', 'cypress-vite-no-support.config.ts'])
cy.startAppServer('component')

cy.visitApp()
cy.contains('App.cy.jsx').click()
cy.get('.passed > .num').should('contain', 1)
})
})
11 changes: 11 additions & 0 deletions npm/webpack-dev-server/cypress/e2e/webpack-dev-server.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('Config options', () => {
it('supports supportFile = false', () => {
cy.scaffoldProject('webpack5_wds4-react')
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-no-support.config.ts'])
cy.startAppServer('component')

cy.visitApp()
cy.contains('App.cy.jsx').click()
cy.get('.passed > .num').should('contain', 1)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress'
import defaultConfig from './cypress-vite.config'

export default defineConfig({
...defaultConfig,
component: {
...defaultConfig.component as Cypress.Config['component'],
supportFile: false
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress'
import defaultConfig from './cypress-webpack.config'

export default defineConfig({
...defaultConfig,
component: {
...defaultConfig.component as Cypress.Config['component'],
supportFile: false
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare global {
}
}

module.exports = defineConfig({
export default defineConfig({
component: {
devServer: {
framework: 'react',
Expand Down