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: framework detection test race condition #6564

Merged
merged 9 commits into from
May 9, 2024
11 changes: 9 additions & 2 deletions src/utils/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,15 @@ export const injectEnvVariables = (env) => {
}
}

// @ts-expect-error TS(7031) FIXME: Binding element 'configuredPort' implicitly has an... Remove this comment to see the full error message
export const acquirePort = async ({ configuredPort, defaultPort, errorMessage }) => {
export const acquirePort = async ({
configuredPort,
defaultPort,
errorMessage,
}: {
configuredPort?: number
defaultPort: number
errorMessage: string
}) => {
const acquiredPort = await getPort({ port: configuredPort || defaultPort })
if (configuredPort && acquiredPort !== configuredPort) {
throw new Error(`${errorMessage}: '${configuredPort}'`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`frameworks/framework-detection > should default to process.cwd() and st
β—ˆ Unable to determine public folder to serve files from. Using current working directory
β—ˆ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
β—ˆ See docs at: https://docs.netlify.com/cli/local-development/#project-detection
β—ˆ Running static server from \\"site-with-index-file\\"
β—ˆ Running static server from \\"should-default-to-process-cwd-and-static-server\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888
Expand Down Expand Up @@ -35,7 +35,7 @@ exports[`frameworks/framework-detection > should filter frameworks with no dev c
β—ˆ Unable to determine public folder to serve files from. Using current working directory
β—ˆ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
β—ˆ See docs at: https://docs.netlify.com/cli/local-development/#project-detection
β—ˆ Running static server from \\"site-with-gulp\\"
β—ˆ Running static server from \\"should-filter-frameworks-with-no-dev-command\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888
Expand All @@ -54,21 +54,6 @@ exports[`frameworks/framework-detection > should force a specific framework when
β—ˆ Failed running command: react-scripts start. Please verify 'react-scripts' exists"
`;

exports[`frameworks/framework-detection > should log the command if using static server and \`command\` is configured 1`] = `
"β—ˆ Netlify Dev β—ˆ
β—ˆ Using simple static server because '--dir' flag was specified
β—ˆ Running static server from \\"site-with-index-file/public\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”‚ β—ˆ Server now ready on http://localhost:88888 β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜"
`;

exports[`frameworks/framework-detection > should not run framework detection if command and targetPort are configured 1`] = `
"β—ˆ Netlify Dev β—ˆ
β—ˆ Unable to determine public folder to serve files from. Using current working directory
Expand Down Expand Up @@ -162,7 +147,7 @@ exports[`frameworks/framework-detection > should throw when forcing a non suppor
exports[`frameworks/framework-detection > should use static server when --dir flag is passed 1`] = `
"β—ˆ Netlify Dev β—ˆ
β—ˆ Using simple static server because '--dir' flag was specified
β—ˆ Running static server from \\"site-with-index-file/public\\"
β—ˆ Running static server from \\"should-use-static-server-when-dir-flag-is-passed/public\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888
Expand All @@ -180,7 +165,7 @@ exports[`frameworks/framework-detection > should use static server when framewor
β—ˆ Unable to determine public folder to serve files from. Using current working directory
β—ˆ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
β—ˆ See docs at: https://docs.netlify.com/cli/local-development/#project-detection
β—ˆ Running static server from \\"site-with-index-file\\"
β—ˆ Running static server from \\"should-use-static-server-when-framework-is-set-to-static\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888
Expand All @@ -197,7 +182,7 @@ exports[`frameworks/framework-detection > should warn if using static server and
β—ˆ Using simple static server because '--dir' flag was specified
β—ˆ Ignoring 'targetPort' setting since using a simple static server.
β—ˆ Use --staticServerPort or [dev.staticServerPort] to configure the static server port
β—ˆ Running static server from \\"site-with-index-file/public\\"
β—ˆ Running static server from \\"should-warn-if-using-static-server-and-target-port-is-configured/public\\"
β—ˆ Setting up local development server

β—ˆ Static server listening to 88888
Expand Down
Loading
Loading