Skip to content

Commit

Permalink
fix: framework detection test race condition (#6564)
Browse files Browse the repository at this point in the history
* chore: replace deprecated buildAsync call

* chore: don't mix await and .then()

* chore: move away from deprecated withSiteBuilder implementation

* test: remove final reference to cleanupAsync and remove function

* test: remove redundant and flaky test

* fix: clean up a few lint warnings
  • Loading branch information
mrstork committed May 9, 2024
1 parent f2b0a5f commit a79430f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 108 deletions.
11 changes: 9 additions & 2 deletions src/utils/dev.ts
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
25 changes: 5 additions & 20 deletions tests/integration/__snapshots__/framework-detection.test.js.snap
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

2 comments on commit a79430f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,347
  • Package size: 312 MB
  • Number of ts-expect-error directives: 996

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,347
  • Package size: 312 MB
  • Number of ts-expect-error directives: 996

Please sign in to comment.