fix: update dev server error message (#21181)

* fix: update dev server error message

* revert change

* remove obsolete test

* revert change

* update errors

* rename error
This commit is contained in:
Lachlan Miller
2022-04-26 12:37:18 +10:00
committed by GitHub
parent 598d94c62a
commit 22e7d36673
8 changed files with 18 additions and 43 deletions

View File

@@ -36,12 +36,14 @@
</head>
<body><pre><span style="color:#e05561">Your <span style="color:#de73ff">configFile<span style="color:#e05561"> is invalid: <span style="color:#4ec4ff">/path/to/config.ts<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">The <span style="color:#e5e510">component.devServer()<span style="color:#e05561"> must be a function with the following signature:<span style="color:#e6e6e6">
<span style="color:#e05561">The <span style="color:#e5e510">component.devServer<span style="color:#e05561"> must be an object with a supported <span style="color:#e5e510">framework<span style="color:#e05561"> and <span style="color:#e5e510">bundler<span style="color:#e05561">.<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff">{<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> component: {<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> devServer (cypressDevServerConfig, devServerConfig) {<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> <span style="color:#4f5666">// start dev server here<span style="color:#4ec4ff"><span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> devServer: {<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> framework: &#39;create-react-app&#39;, <span style="color:#4f5666">// Your framework<span style="color:#4ec4ff"><span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> bundler: &#39;webpack&#39; <span style="color:#4f5666">// Your dev server<span style="color:#4ec4ff"><span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> }<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff"> }<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#4ec4ff">}<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
@@ -50,5 +52,5 @@
<span style="color:#e05561"><span style="color:#de73ff">{}<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6">
<span style="color:#e05561">Learn more: https://on.cypress.io/dev-server<span style="color:#e6e6e6">
<span style="color:#e05561"><span style="color:#e6e6e6"></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span style="color:#e05561"><span style="color:#e6e6e6"></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
</pre></body></html>

View File

@@ -1341,20 +1341,24 @@ export const AllCypressErrors = {
https://on.cypress.io/migration-guide`
},
CONFIG_FILE_DEV_SERVER_IS_NOT_A_FUNCTION: (configFilePath: string, setupNodeEvents: any) => {
CONFIG_FILE_DEV_SERVER_IS_NOT_VALID: (configFilePath: string, setupNodeEvents: any) => {
const re = /.?(cypress\.config.*)/
const configFile = configFilePath.match(re)?.[1] ?? `configFile`
const code = errPartial`
{
component: {
devServer (cypressDevServerConfig, devServerConfig) {
${fmt.comment(`// start dev server here`)
devServer: {
framework: 'create-react-app', ${fmt.comment('// Your framework')}
bundler: 'webpack' ${fmt.comment('// Your dev server')}
}
}
}`
return errTemplate`\
Your ${fmt.highlightSecondary(`configFile`)} is invalid: ${fmt.path(configFilePath)}
Your ${fmt.highlightSecondary(configFile)} is invalid: ${fmt.path(configFilePath)}
The ${fmt.highlight(`component.devServer()`)} must be a function with the following signature:
The ${fmt.highlight(`component.devServer`)} must be an object with a supported ${fmt.highlight('framework')} and ${fmt.highlight('bundler')}.
${fmt.code(code)}

View File

@@ -1102,7 +1102,7 @@ describe('visual error templates', () => {
default: [{ name: 'indexHtmlFile', configFile: '/path/to/cypress.config.js.ts' }],
}
},
CONFIG_FILE_DEV_SERVER_IS_NOT_A_FUNCTION: () => {
CONFIG_FILE_DEV_SERVER_IS_NOT_VALID: () => {
return {
default: ['/path/to/config.ts', {}],
}

View File

@@ -510,7 +510,7 @@ enum ErrorTypeEnum {
CHROME_WEB_SECURITY_NOT_SUPPORTED
COMPONENT_FOLDER_REMOVED
CONFIG_FILES_LANGUAGE_CONFLICT
CONFIG_FILE_DEV_SERVER_IS_NOT_A_FUNCTION
CONFIG_FILE_DEV_SERVER_IS_NOT_VALID
CONFIG_FILE_INVALID_DEV_START_EVENT
CONFIG_FILE_INVALID_ROOT_CONFIG
CONFIG_FILE_INVALID_ROOT_CONFIG_COMPONENT

View File

@@ -82,7 +82,7 @@ function run (ipc, file, projectRoot) {
}
ipc.send('setupTestingType:error', util.serializeError(
require('@packages/errors').getError('CONFIG_FILE_DEV_SERVER_IS_NOT_A_FUNCTION', file, config),
require('@packages/errors').getError('CONFIG_FILE_DEV_SERVER_IS_NOT_VALID', file, config),
))
return false

View File

@@ -1,18 +0,0 @@
exports['devServer dynamic import throws error when devServer use dynamic import instead of require 1'] = `
The \`component\`.\`devServer\` method must be a function with the following signature:
\`\`\`
devServer: (cypressDevServerConfig, devServerConfig) {
// start dev server here
}
\`\`\`
Learn more: https://on.cypress.io/dev-server
We loaded the \`devServer\` from: \`/foo/bar/.projects/devServer-dynamic-import/cypress.config.js\`
It exported:
{"supportFile":false,"devServer":{},"devServerConfig":{"webpackFilename":"webpack.config.js"}}
`

View File

@@ -1,3 +0,0 @@
{
"parser": "babel-eslint"
}

View File

@@ -1,10 +0,0 @@
module.exports = {
component: {
supportFile: false,
devServer: {
framework: 'react',
bundler: 'webpack',
webpackConfig: require('./webpack.config'),
},
},
}