fix: framework detection test race condition #6564
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes CT-1094
This solves the race condition and flakiness of test
frameworks/framework-detection > should log the command if using static server and command is configured
by removing it (justifiably, see explanation below). This also presents asIntegration Tests / Integration (macOS-latest, 22, 4/4)
failing in the test suite.Explanation:
This test runs
ntl dev --dir public --command npm run start
in the test directory. When I run this command manually, I get the following error page:This site can’t be reached. localhost refused to connect.
. Interestingly, I can sometimes get the page to show up if I close and re-open the tab, however I believe this is due to the browser caching a working copy.The root of the problem is that
npm run start
relies on apackage.json
file, and ascripts
declaration, which this test is not setting up. From there,npm
throws an error (Command failed with exit code 1: npm. Shutting down Netlify Dev server
), shutting down the static server before it can be queried (hencesocket hang up
), and thus failing the test assertion around site content.When the test works, I believe it's either due to the browser caching a functioning site (perhaps of another site running in parallel, or one that ran just before), or there is actually a tiny window of time in which the static server is up, before
npm run start
fails.Fix:
I've opted to remove the test case as it is testing a scenario that doesn't actually work in practice.
Alternate Solutions Considered:
I am happy to switch to any of these options (or something else entirely) if that's preferred.
fetch
, and simply look at console outputnpm
fails before the test finishesnpm run start
->echo hello
, and simply verify the output of the cli matches what's expected.package.json
file with a valid start scriptBonus Changes:
Extra changes in this pull request:
withSiteBuilder
(and update associated snapshots)buildAsync -> build
in the test file to remove deprecation warningscleanupAsync
and remove the methodacquirePort
,await
and.then()
in a single statement (code style preference)For us to review and ship your PR efficiently, please perform the following steps:
Open a bug/issue before writing your code 🧑💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.passes our tests.
Update or add documentation (if features were changed or added) 📝