fix(cypress/webpack-dev-server): correct path for indexHtmlFile (#27320)

* fix: correct path for indexHtmlt

* changelog
This commit is contained in:
Lachlan Miller
2023-08-04 14:54:38 +10:00
committed by GitHub
parent 14a7416e12
commit 53fd537a04
8 changed files with 3247 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ _Released 07/20/2023_
- Fixed an issue where commands would fail with the error `must only be invoked from the spec file or support file` if their arguments were mutated. Fixes [#27200](https://github.com/cypress-io/cypress/issues/27200).
- Fixed an issue where `cy.writeFile()` would erroneously fail with the error `cy.writeFile() must only be invoked from the spec file or support file`. Fixes [#27097](https://github.com/cypress-io/cypress/issues/27097).
- Fixed an issue where web workers could not be created within a spec. Fixes [#27298](https://github.com/cypress-io/cypress/issues/27298).
- Fixed an issue where having `cypress.config` in a nested directory would cause problems with locating the `component-index.html` file when using component testing. Fixes [#26400](https://github.com/cypress-io/cypress/issues/26400).
## 12.17.1

View File

@@ -12,6 +12,17 @@ describe('Config options', () => {
cy.get('.passed > .num').should('contain', 1)
})
it('supports nested config', () => {
cy.scaffoldProject('webpack-react-nested-config')
cy.openProject('webpack-react-nested-config', ['--config-file', 'cypress/cypress.config.js'])
cy.startAppServer('component')
cy.visitApp()
cy.contains('foo.cy.js').click()
cy.waitForSpecToFinish()
cy.get('.passed > .num').should('contain', 1)
})
it('supports @cypress/webpack-dev-server', () => {
cy.scaffoldProject('webpack5_wds4-react')
cy.openProject('webpack5_wds4-react', ['--config-file', 'cypress-webpack-dev-server-function.config.ts'])

View File

@@ -78,7 +78,7 @@ export function makeCypressWebpackConfig (
},
plugins: [
new (HtmlWebpackPlugin as typeof import('html-webpack-plugin-5'))({
template: indexHtmlFile,
template: indexHtmlFile ? path.join(projectRoot, indexHtmlFile) : undefined,
// Angular generates all of it's scripts with <script type="module">. Live-reloading breaks without this option.
// We need to manually set the base here to `/__cypress/src/` so that static assets load with our proxy
...(framework === 'angular' ? { scriptLoading: 'module', base: '/__cypress/src/' } : {}),

View File

@@ -0,0 +1,10 @@
const { devServer } = require('@cypress/webpack-dev-server')
module.exports = {
component: {
supportFile: false,
devServer: (args) => {
return devServer({ ...args, webpackConfig: {} })
},
},
}

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>

View File

@@ -0,0 +1,7 @@
{
"devDependencies": {
"@cypress/webpack-dev-server": "file:../../../npm/webpack-dev-server",
"webpack": "^5",
"webpack-dev-server": "^4"
}
}

View File

@@ -0,0 +1,3 @@
it('renders hello world', () => {
expect(1).to.eq(1)
})

File diff suppressed because it is too large Load Diff