mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-04 22:30:00 -06:00
* breaking: dropping support for webpack-dev-server 3 from @cypress/webpack-dev-server
BREAKING CHANGE: support for webpack-dev-server version 3 has been removed. webpack-dev-server 3 is no longer maintained by the webpack team. To reduce overhead, Cypress is now removing support in Cypress 14.
* update create-react-app-configured/unconfigured
* updated vueclivue2-configured to use vue cli v5
* updated vueclivue2-unconfigured to use vue cli v5
* updated vueclivue3-unconfigured to use vue cli v5
* updated vueclivue3-configured to use vue cli v5
* updated vueclivue3-custom-index-html to use vue cli v5
* update react17 project to use webpack-dev-server v4 (default ships v5 which does not work with webpack 4)
* update react18 project to use webpack-dev-server v4 (default ships v5 which does not work with webpack 4)
* update nuxt version to avoid some issues in the preprocessed webpack config
* update cy in cy component scaffolding tests to run on more suites, as well as skip config warning for outdated vuecli3 as it will throw due to wds being on version 3. this is a VERY old version, and the test needs to be updated to use vuecli5 so we get wds v5 (vuecli5 support will be deprecated)
* no longer support cra v4 and vue/cli-service v4
* remove cra v4 and vue cli service v4 detect tests as they are no longer supported [run ci]
* chore: update cra app custom index to use cra 5 [run ci]
* update protocol spec snapshot [run ci]
* chore: remove stale references to old vuecli system tests [run ci]
* update webpack-dev-server-4 to actually be wds 4 [run ci]
* add changelog entry [run ci]
* update cache key and tests that should not pass [run ci]
* add issue to changelog entry
* no longer clean up default-gateway as it was shipped with webpack-dev-server 4, which is now a dev dependency [run ci]
* fix issues with node-ipc being out of date [run ci]
* move changelog to correct section [run ci]
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
import * as Fixtures from '@tooling/system-tests'
|
|
import * as FixturesScaffold from '@tooling/system-tests/lib/dep-installer'
|
|
import type { fixtureDirs } from '@tooling/system-tests'
|
|
import { expect } from 'chai'
|
|
import path from 'path'
|
|
import fs from 'fs'
|
|
|
|
import { sourceDefaultWebpackDependencies } from '../src/helpers/sourceRelativeWebpackModules'
|
|
import { WebpackDevServerConfig } from '../src/devServer'
|
|
import './support'
|
|
|
|
type ProjectDirs = typeof fixtureDirs
|
|
|
|
const CY_ROOT = path.join(__dirname, '..', '..', '..')
|
|
|
|
const WEBPACK_REACT: Partial<Record<ProjectDirs[number], {
|
|
webpack: number
|
|
webpackDevServer: number
|
|
htmlWebpackPlugin: number
|
|
}>> = {
|
|
'webpack4_wds4-react': {
|
|
webpack: 4,
|
|
webpackDevServer: 4,
|
|
htmlWebpackPlugin: 4,
|
|
},
|
|
'webpack5_wds4-react': {
|
|
webpack: 5,
|
|
webpackDevServer: 4,
|
|
htmlWebpackPlugin: 5,
|
|
},
|
|
'webpack5_wds5-react': {
|
|
webpack: 5,
|
|
webpackDevServer: 5,
|
|
htmlWebpackPlugin: 5,
|
|
},
|
|
}
|
|
|
|
async function sourceModulesForProject (fixture: ProjectDirs[number]) {
|
|
Fixtures.remove()
|
|
const projectRoot = await Fixtures.scaffoldProject(fixture)
|
|
|
|
await FixturesScaffold.scaffoldProjectNodeModules({ project: fixture })
|
|
|
|
const result = sourceDefaultWebpackDependencies({
|
|
cypressConfig: {
|
|
projectRoot,
|
|
},
|
|
} as WebpackDevServerConfig)
|
|
|
|
return { result, projectRoot }
|
|
}
|
|
|
|
// Ensures that we are properly sourcing the webpacks from the node_modules in the given project,
|
|
// rather than from the node_modules in the project root
|
|
describe('sourceDefaultWebpackDependencies', () => {
|
|
for (const [fixture, versionsToMatch] of Object.entries(WEBPACK_REACT)) {
|
|
describe(fixture, () => {
|
|
it(`sources the correct webpack versions for ${fixture}`, async () => {
|
|
const { result, projectRoot } = await sourceModulesForProject(fixture as ProjectDirs[number])
|
|
const projectNodeModules = fs.realpathSync(path.resolve(projectRoot, 'node_modules'))
|
|
|
|
expect(result.webpack.majorVersion).to.eq(versionsToMatch.webpack, 'match webpackVersion')
|
|
expect(result.webpackDevServer.majorVersion).to.eq(versionsToMatch.webpackDevServer, 'match webpackDevServerVersion')
|
|
expect(result.webpack.importPath).to.include(projectNodeModules)
|
|
expect(result.webpackDevServer.importPath).to.include(projectNodeModules)
|
|
})
|
|
})
|
|
}
|
|
|
|
it('sources the webpack path from the correct location once imported', async () => {
|
|
expect(require.resolve('webpack')).to.include(CY_ROOT)
|
|
const localWebpack = require('webpack')
|
|
|
|
const { result, projectRoot } = await sourceModulesForProject('webpack5_wds5-react')
|
|
const projectNodeModules = fs.realpathSync(path.resolve(projectRoot, 'node_modules'))
|
|
|
|
expect(localWebpack).not.to.eq(result.webpack.module)
|
|
expect(result.webpack.importPath).to.include(projectNodeModules)
|
|
expect(result.webpack.majorVersion).to.eq(5, 'match webpackVersion')
|
|
expect(require('webpack')).to.eq(result.webpack.module)
|
|
expect(require.resolve('webpack')).to.include(projectNodeModules)
|
|
})
|
|
})
|