Skip to content

Commit

Permalink
feat: component testing now supports vite 6 [run ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
AtofStryker committed Nov 26, 2024
1 parent f4aec3e commit b2d0c3b
Show file tree
Hide file tree
Showing 16 changed files with 2,101 additions and 193 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ in this [GitHub issue](https://github.com/cypress-io/cypress/issues/30447). Addr

- Cypress Component Testing now supports `React` version 19. Cypress will allow detected use of the React 19 Release Candidate until React 19 is officially released. Addresses [#29470](https://github.com/cypress-io/cypress/issues/29470).
- Cypress Component Testing now supports `Next.js` version 15. Addresses [#30445](https://github.com/cypress-io/cypress/issues/30445).
- Cypress Component Testing now supports `Vite` version 6. Addresses [#30591](https://github.com/cypress-io/cypress/issues/30591).

**Bugfixes:**

Expand Down
2 changes: 1 addition & 1 deletion npm/vite-dev-server/cypress/e2e/react.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dedent from 'dedent'

type ProjectDirs = typeof fixtureDirs

const VITE_REACT: ProjectDirs[number][] = ['vite4.5.5-react', 'vite5.4.10-react']
const VITE_REACT: ProjectDirs[number][] = ['vite4.5.5-react', 'vite5.4.10-react', 'vite6.0.0-react']

// Add to this list to focus on a particular permutation
const ONLY_PROJECTS: ProjectDirs[number][] = []
Expand Down
20 changes: 10 additions & 10 deletions npm/vite-dev-server/cypress/e2e/vite-dev-server.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('Config options', () => {
})

it('supports supportFile = false', () => {
cy.scaffoldProject('vite5.4.10-react')
cy.openProject('vite5.4.10-react', ['--config-file', 'cypress-vite-no-support.config.ts', '--component'])
cy.scaffoldProject('vite6.0.0-react')
cy.openProject('vite6.0.0-react', ['--config-file', 'cypress-vite-no-support.config.ts', '--component'])
cy.startAppServer('component')

cy.visitApp()
Expand All @@ -59,8 +59,8 @@ describe('Config options', () => {
it('supports serving files with whitespace', () => {
const specWithWhitespace = 'spec with whitespace.cy.jsx'

cy.scaffoldProject('vite5.4.10-react')
cy.openProject('vite5.4.10-react', ['--config-file', 'cypress-vite.config.ts', '--component'])
cy.scaffoldProject('vite6.0.0-react')
cy.openProject('vite6.0.0-react', ['--config-file', 'cypress-vite.config.ts', '--component'])
cy.startAppServer('component')

cy.withCtx(async (ctx, { specWithWhitespace }) => {
Expand All @@ -77,8 +77,8 @@ describe('Config options', () => {
})

it('supports @cypress/vite-dev-server', () => {
cy.scaffoldProject('vite5.4.10-react')
cy.openProject('vite5.4.10-react', ['--config-file', 'cypress-vite-dev-server-function.config.ts', '--component'])
cy.scaffoldProject('vite6.0.0-react')
cy.openProject('vite6.0.0-react', ['--config-file', 'cypress-vite-dev-server-function.config.ts', '--component'])
cy.startAppServer('component')

cy.visitApp()
Expand All @@ -89,8 +89,8 @@ describe('Config options', () => {
})

it('supports viteConfig as an async function', () => {
cy.scaffoldProject('vite5.4.10-react')
cy.openProject('vite5.4.10-react', ['--config-file', 'cypress-vite-async-function-config.config.ts', '--component'])
cy.scaffoldProject('vite6.0.0-react')
cy.openProject('vite6.0.0-react', ['--config-file', 'cypress-vite-async-function-config.config.ts', '--component'])
cy.startAppServer('component')

cy.visitApp()
Expand Down Expand Up @@ -120,8 +120,8 @@ describe('sourcemaps', () => {
})
`

cy.scaffoldProject('vite5.4.10-react')
cy.openProject('vite5.4.10-react', ['--config-file', 'cypress-vite.config.ts', '--component'])
cy.scaffoldProject('vite6.0.0-react')
cy.openProject('vite6.0.0-react', ['--config-file', 'cypress-vite.config.ts', '--component'])
cy.startAppServer('component')

cy.withCtx(async (ctx, o) => {
Expand Down
1 change: 1 addition & 0 deletions npm/vite-dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"ts-node": "^10.9.2",
"vite-4": "npm:vite@^4.5.3",
"vite-5": "npm:vite@^5.2.8",
"vite-6": "npm:vite@^6.0.0",
"vite-plugin-inspect": "0.8.4"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion npm/vite-dev-server/src/devServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import debugFn from 'debug'
import semverMajor from 'semver/functions/major'
import type { UserConfig } from 'vite-5'
import type { UserConfig } from 'vite-6'
import { getVite, Vite } from './getVite'
import { createViteDevServerConfig } from './resolveConfig'

Expand Down
2 changes: 1 addition & 1 deletion npm/vite-dev-server/src/getVite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ViteDevServerConfig } from './devServer'

const debug = debugFn('cypress:vite-dev-server:getVite')

export type Vite = typeof import('vite-5')
export type Vite = typeof import('vite-6')

// "vite-dev-server" is bundled in the binary, so we need to require.resolve "vite"
// from root of the active project since we don't bundle vite internally but rather
Expand Down
2 changes: 1 addition & 1 deletion npm/vite-dev-server/src/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You can find it here https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/create.ts
*/
import debugFn from 'debug'
import type { InlineConfig } from 'vite-5'
import type { InlineConfig } from 'vite-6'
import path from 'path'
import semverGte from 'semver/functions/gte'

Expand Down
7 changes: 6 additions & 1 deletion npm/vite-dev-server/test/resolveConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Chai, { expect } from 'chai'
import { EventEmitter } from 'events'
import * as vite4 from 'vite-4'
import * as vite5 from 'vite-5'
import * as vite6 from 'vite-6'
import { scaffoldSystemTestProject } from './test-helpers/scaffoldProject'
import { createViteDevServerConfig } from '../src/resolveConfig'
import sinon from 'sinon'
Expand All @@ -22,7 +23,7 @@ const getViteDevServerConfig = (projectRoot: string) => {
framework: 'react',
} as unknown as ViteDevServerConfig
}
const MAJOR_VERSIONS: ({version: 4, vite: any } | {version: 5, vite: any })[] = [
const MAJOR_VERSIONS: ({version: 4, vite: any } | {version: 5, vite: any } | {version: 6, vite: any })[] = [
{
version: 4,
vite: vite4,
Expand All @@ -31,6 +32,10 @@ const MAJOR_VERSIONS: ({version: 4, vite: any } | {version: 5, vite: any })[] =
version: 5,
vite: vite5,
},
{
version: 6,
vite: vite6,
},
]

describe('resolveConfig', function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/scaffold-config/src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const WIZARD_DEPENDENCY_VITE = {
package: 'vite',
installer: 'vite',
description: 'Vite is dev server that serves your source files over native ES modules',
minVersion: '^4.0.0 || ^5.0.0',
minVersion: '^4.0.0 || ^5.0.0 || ^6.0.0',
} as const

export const WIZARD_DEPENDENCY_NEXT = {
Expand Down
Loading

0 comments on commit b2d0c3b

Please sign in to comment.