From 1e7ed8c4a68c1436a146f1426eb6fbd6e847397c Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 15:14:58 -0400 Subject: [PATCH 1/6] chore: replace deprecated buildAsync call --- tests/integration/framework-detection.test.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/integration/framework-detection.test.js b/tests/integration/framework-detection.test.js index 1ab1ce5a12b..6484c99945f 100644 --- a/tests/integration/framework-detection.test.js +++ b/tests/integration/framework-detection.test.js @@ -18,7 +18,7 @@ describe.concurrent('frameworks/framework-detection', () => { path: 'index.html', content, }) - .buildAsync() + .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { const response = await fetch(url).then((res) => res.text()) @@ -36,7 +36,7 @@ describe.concurrent('frameworks/framework-detection', () => { path: 'public/index.html', content, }) - .buildAsync() + .build() await withDevServer({ cwd: builder.directory, args: ['--dir', 'public'] }, async ({ output, url }) => { const response = await fetch(url).then((res) => res.text()) @@ -55,7 +55,7 @@ describe.concurrent('frameworks/framework-detection', () => { content, }) .withNetlifyToml({ config: { dev: { framework: '#static' } } }) - .buildAsync() + .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { const response = await fetch(url).then((res) => res.text()) @@ -76,7 +76,7 @@ describe.concurrent('frameworks/framework-detection', () => { path: 'public/index.html', content, }) - .buildAsync() + .build() await withDevServer( { cwd: builder.directory, args: ['--dir', 'public', '--command', 'npm run start'] }, @@ -97,7 +97,7 @@ describe.concurrent('frameworks/framework-detection', () => { path: 'public/index.html', content, }) - .buildAsync() + .build() await withDevServer( { cwd: builder.directory, args: ['--dir', 'public', '--target-port', '3000'] }, @@ -113,7 +113,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should run `command` when both `command` and `targetPort` are configured', async (t) => { await withSiteBuilder('empty-site', async (builder) => { - await builder.withNetlifyToml({ config: { build: { publish: 'public' } } }).buildAsync() + await builder.withNetlifyToml({ config: { build: { publish: 'public' } } }).build() // a failure is expected since we use `echo hello` instead of starting a server const error = await withDevServer( @@ -128,7 +128,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should force a specific framework when configured', async (t) => { await withSiteBuilder('site-with-mocked-cra', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: 'create-react-app' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: 'create-react-app' } } }).build() // a failure is expected since this is not a true create-react-app project const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -138,7 +138,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should throw when forcing a non supported framework', async (t) => { await withSiteBuilder('site-with-unknown-framework', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: 'to-infinity-and-beyond-js' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: 'to-infinity-and-beyond-js' } } }).build() const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) t.expect(normalize(error.stdout, { duration: true, filePath: true })).toMatchSnapshot() @@ -151,7 +151,7 @@ describe.concurrent('frameworks/framework-detection', () => { .withPackageJson({ packageJson: { dependencies: { 'react-scripts': '1.0.0' }, scripts: { start: 'react-scripts start' } }, }) - .buildAsync() + .build() // a failure is expected since this is not a true create-react-app project const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -161,7 +161,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should throw if framework=#custom but command is missing', async (t) => { await withSiteBuilder('site-with-framework-and-no-command', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).build() const error = await withDevServer( { cwd: builder.directory, args: ['--target-port', '3000'] }, @@ -174,7 +174,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should throw if framework=#custom but targetPort is missing', async (t) => { await withSiteBuilder('site-with-framework-and-no-command', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).build() const error = await withDevServer( { cwd: builder.directory, args: ['--command', 'echo hello'] }, @@ -187,7 +187,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should start custom command if framework=#custom, command and targetPort are configured', async (t) => { await withSiteBuilder('site-with-custom-framework', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: '#custom', publish: 'public' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: '#custom', publish: 'public' } } }).build() const error = await withDevServer( { cwd: builder.directory, args: ['--command', 'echo hello', '--target-port', '3000'] }, @@ -200,7 +200,7 @@ describe.concurrent('frameworks/framework-detection', () => { test(`should print specific error when command doesn't exist`, async (t) => { await withSiteBuilder('site-with-custom-framework', async (builder) => { - await builder.buildAsync() + await builder.build() const error = await withDevServer( { @@ -232,7 +232,7 @@ describe.concurrent('frameworks/framework-detection', () => { }, }) .withContentFile({ path: 'gatsby-config.js', content: '' }) - .buildAsync() + .build() // a failure is expected since this is not a true framework project const asyncErrorBlock = async () => { @@ -266,7 +266,7 @@ describe.concurrent('frameworks/framework-detection', () => { }, }) .withContentFile({ path: 'gatsby-config.js', content: '' }) - .buildAsync() + .build() // a failure is expected since this is not a true framework project const asyncErrorBlock = async () => { @@ -289,7 +289,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should not run framework detection if command and targetPort are configured', async (t) => { await withSiteBuilder('site-with-hugo-config', async (builder) => { - await builder.withContentFile({ path: 'config.toml', content: '' }).buildAsync() + await builder.withContentFile({ path: 'config.toml', content: '' }).build() // a failure is expected since the command exits early const error = await withDevServer( @@ -312,7 +312,7 @@ describe.concurrent('frameworks/framework-detection', () => { .withPackageJson({ packageJson: { dependencies: { gulp: '1.0.0' } }, }) - .buildAsync() + .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { const response = await fetch(url).then((res) => res.text()) @@ -332,7 +332,7 @@ describe.concurrent('frameworks/framework-detection', () => { scripts: { dev: 'node -p process.env.NODE_VERSION' }, }, }) - .buildAsync() + .build() // a failure is expected since this is not a true Gatsby project const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -342,7 +342,7 @@ describe.concurrent('frameworks/framework-detection', () => { test('should start static service for frameworks without port, forced framework', async (t) => { await withSiteBuilder('site-with-remix', async (builder) => { - await builder.withNetlifyToml({ config: { dev: { framework: 'remix' } } }).buildAsync() + await builder.withNetlifyToml({ config: { dev: { framework: 'remix' } } }).build() // a failure is expected since this is not a true remix project const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -360,7 +360,7 @@ describe.concurrent('frameworks/framework-detection', () => { }, }) .withContentFile({ path: 'remix.config.js', content: '' }) - .buildAsync() + .build() // a failure is expected since this is not a true remix project const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -405,7 +405,7 @@ describe.concurrent('frameworks/framework-detection', () => { }, }, }) - .buildAsync() + .build() await withDevServer( { cwd: builder.directory, context: null, debug: true, serve: true }, From 9cac2147402e0afdb9cf035e8c8ee3db2c9c683f Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 15:18:28 -0400 Subject: [PATCH 2/6] chore: don't mix await and .then() --- tests/integration/framework-detection.test.js | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/integration/framework-detection.test.js b/tests/integration/framework-detection.test.js index 6484c99945f..cc0ae5f99bb 100644 --- a/tests/integration/framework-detection.test.js +++ b/tests/integration/framework-detection.test.js @@ -21,9 +21,10 @@ describe.concurrent('frameworks/framework-detection', () => { .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }) }) @@ -39,9 +40,10 @@ describe.concurrent('frameworks/framework-detection', () => { .build() await withDevServer({ cwd: builder.directory, args: ['--dir', 'public'] }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }) }) @@ -58,9 +60,10 @@ describe.concurrent('frameworks/framework-detection', () => { .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }) }) @@ -81,9 +84,10 @@ describe.concurrent('frameworks/framework-detection', () => { await withDevServer( { cwd: builder.directory, args: ['--dir', 'public', '--command', 'npm run start'] }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }, ) @@ -102,9 +106,10 @@ describe.concurrent('frameworks/framework-detection', () => { await withDevServer( { cwd: builder.directory, args: ['--dir', 'public', '--target-port', '3000'] }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }, ) @@ -315,9 +320,10 @@ describe.concurrent('frameworks/framework-detection', () => { .build() await withDevServer({ cwd: builder.directory }, async ({ output, url }) => { - const response = await fetch(url).then((res) => res.text()) - t.expect(response).toEqual(content) + const response = await fetch(url) + const responseContent = await response.text() + t.expect(responseContent).toEqual(content) t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() }) }) @@ -410,8 +416,9 @@ describe.concurrent('frameworks/framework-detection', () => { await withDevServer( { cwd: builder.directory, context: null, debug: true, serve: true }, async ({ output, url }) => { - const response = await fetch(`${url}/hello`).then((res) => res.json()) - t.expect(response).toStrictEqual({ CONTEXT_CHECK: 'PRODUCTION' }) + const response = await fetch(`${url}/hello`) + const responseJson = await response.json() + t.expect(responseJson).toStrictEqual({ CONTEXT_CHECK: 'PRODUCTION' }) const normalizedText = normalize(output, { duration: true, filePath: true }) t.expect( From 8e4b8126e1ce020c05502b26bac168d5a01e1beb Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 15:39:40 -0400 Subject: [PATCH 3/6] chore: move away from deprecated withSiteBuilder implementation --- .../framework-detection.test.js.snap | 12 +++--- tests/integration/framework-detection.test.js | 42 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/integration/__snapshots__/framework-detection.test.js.snap b/tests/integration/__snapshots__/framework-detection.test.js.snap index 95c47bd12ac..54fb0c89f92 100644 --- a/tests/integration/__snapshots__/framework-detection.test.js.snap +++ b/tests/integration/__snapshots__/framework-detection.test.js.snap @@ -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 @@ -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 @@ -57,7 +57,7 @@ exports[`frameworks/framework-detection > should force a specific framework when 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\\" +◈ Running static server from \\"should-log-the-command-if-using-static-server-and-command-is-configured/public\\" ◈ Setting up local development server ◈ Static server listening to 88888 @@ -162,7 +162,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 @@ -180,7 +180,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 @@ -197,7 +197,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 diff --git a/tests/integration/framework-detection.test.js b/tests/integration/framework-detection.test.js index cc0ae5f99bb..a36263c202f 100644 --- a/tests/integration/framework-detection.test.js +++ b/tests/integration/framework-detection.test.js @@ -12,7 +12,7 @@ const content = 'Hello World!' describe.concurrent('frameworks/framework-detection', () => { test('should default to process.cwd() and static server', async (t) => { - await withSiteBuilder('site-with-index-file', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'index.html', @@ -31,7 +31,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should use static server when --dir flag is passed', async (t) => { - await withSiteBuilder('site-with-index-file', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'public/index.html', @@ -50,7 +50,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should use static server when framework is set to #static', async (t) => { - await withSiteBuilder('site-with-index-file', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'index.html', @@ -73,7 +73,7 @@ describe.concurrent('frameworks/framework-detection', () => { // Running it in isolation (or removing the '.concurrent' on the describe block above) // fixes it. See CT-1094 for more details test('should log the command if using static server and `command` is configured', async (t) => { - await withSiteBuilder('site-with-index-file', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'public/index.html', @@ -95,7 +95,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should warn if using static server and `targetPort` is configured', async (t) => { - await withSiteBuilder('site-with-index-file', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'public/index.html', @@ -117,7 +117,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should run `command` when both `command` and `targetPort` are configured', async (t) => { - await withSiteBuilder('empty-site', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { build: { publish: 'public' } } }).build() // a failure is expected since we use `echo hello` instead of starting a server @@ -132,7 +132,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should force a specific framework when configured', async (t) => { - await withSiteBuilder('site-with-mocked-cra', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: 'create-react-app' } } }).build() // a failure is expected since this is not a true create-react-app project @@ -142,7 +142,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should throw when forcing a non supported framework', async (t) => { - await withSiteBuilder('site-with-unknown-framework', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: 'to-infinity-and-beyond-js' } } }).build() const error = await withDevServer({ cwd: builder.directory }, () => {}, true).catch((error_) => error_) @@ -151,7 +151,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should detect a known framework', async (t) => { - await withSiteBuilder('site-with-cra', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withPackageJson({ packageJson: { dependencies: { 'react-scripts': '1.0.0' }, scripts: { start: 'react-scripts start' } }, @@ -165,7 +165,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should throw if framework=#custom but command is missing', async (t) => { - await withSiteBuilder('site-with-framework-and-no-command', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).build() const error = await withDevServer( @@ -178,7 +178,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should throw if framework=#custom but targetPort is missing', async (t) => { - await withSiteBuilder('site-with-framework-and-no-command', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: '#custom' } } }).build() const error = await withDevServer( @@ -191,7 +191,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should start custom command if framework=#custom, command and targetPort are configured', async (t) => { - await withSiteBuilder('site-with-custom-framework', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: '#custom', publish: 'public' } } }).build() const error = await withDevServer( @@ -204,7 +204,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test(`should print specific error when command doesn't exist`, async (t) => { - await withSiteBuilder('site-with-custom-framework', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.build() const error = await withDevServer( @@ -228,7 +228,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should prompt when multiple frameworks are detected', async (t) => { - await withSiteBuilder('site-with-multiple-frameworks', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withPackageJson({ packageJson: { @@ -262,7 +262,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should fail in CI when multiple frameworks are detected', async (t) => { - await withSiteBuilder('site-with-multiple-frameworks', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withPackageJson({ packageJson: { @@ -293,7 +293,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should not run framework detection if command and targetPort are configured', async (t) => { - await withSiteBuilder('site-with-hugo-config', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withContentFile({ path: 'config.toml', content: '' }).build() // a failure is expected since the command exits early @@ -308,7 +308,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should filter frameworks with no dev command', async (t) => { - await withSiteBuilder('site-with-gulp', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withContentFile({ path: 'index.html', @@ -330,7 +330,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should pass framework-info env to framework sub process', async (t) => { - await withSiteBuilder('site-with-gatsby', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withPackageJson({ packageJson: { @@ -347,7 +347,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should start static service for frameworks without port, forced framework', async (t) => { - await withSiteBuilder('site-with-remix', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder.withNetlifyToml({ config: { dev: { framework: 'remix' } } }).build() // a failure is expected since this is not a true remix project @@ -357,7 +357,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should start static service for frameworks without port, detected framework', async (t) => { - await withSiteBuilder('site-with-remix', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withPackageJson({ packageJson: { @@ -375,7 +375,7 @@ describe.concurrent('frameworks/framework-detection', () => { }) test('should run and serve a production build when using the `serve` command', async (t) => { - await withSiteBuilder('site-with-framework', async (builder) => { + await withSiteBuilder(t, async (builder) => { await builder .withNetlifyToml({ config: { From cf3c11581d8bc37fc43a079faeecb008b00ac5fb Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 18:48:55 -0400 Subject: [PATCH 4/6] test: remove final reference to cleanupAsync and remove function --- tests/integration/utils/site-builder.ts | 7 ------- tests/unit/utils/headers.test.js | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/integration/utils/site-builder.ts b/tests/integration/utils/site-builder.ts index 3a126a2242b..88ff6018e91 100644 --- a/tests/integration/utils/site-builder.ts +++ b/tests/integration/utils/site-builder.ts @@ -273,13 +273,6 @@ export class SiteBuilder { return this } - - /** - * @deprecated - */ - async cleanupAsync() { - return this.cleanup() - } } export const createSiteBuilder = ({ siteName }: { siteName: string }) => { diff --git a/tests/unit/utils/headers.test.js b/tests/unit/utils/headers.test.js index 75c2a306bce..e2d13f82800 100644 --- a/tests/unit/utils/headers.test.js +++ b/tests/unit/utils/headers.test.js @@ -73,13 +73,13 @@ describe('_headers', () => { `, }) - await builder.buildAsync() + await builder.build() context.builder = builder }) afterEach(async (context) => { - await context.builder.cleanupAsync() + await context.builder.cleanup() }) test('syntax validates as expected', async (context) => { From adfd1224ea165102d4c009e0d3af8080b5dd20f3 Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 19:43:57 -0400 Subject: [PATCH 5/6] test: remove redundant and flaky test --- .../framework-detection.test.js.snap | 15 ----------- tests/integration/framework-detection.test.js | 25 ------------------- 2 files changed, 40 deletions(-) diff --git a/tests/integration/__snapshots__/framework-detection.test.js.snap b/tests/integration/__snapshots__/framework-detection.test.js.snap index 54fb0c89f92..904312630e5 100644 --- a/tests/integration/__snapshots__/framework-detection.test.js.snap +++ b/tests/integration/__snapshots__/framework-detection.test.js.snap @@ -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 \\"should-log-the-command-if-using-static-server-and-command-is-configured/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 diff --git a/tests/integration/framework-detection.test.js b/tests/integration/framework-detection.test.js index a36263c202f..41018cbfac7 100644 --- a/tests/integration/framework-detection.test.js +++ b/tests/integration/framework-detection.test.js @@ -69,31 +69,6 @@ describe.concurrent('frameworks/framework-detection', () => { }) }) - // This test has a race condition that occasionally causes it to fail when run concurrently. - // Running it in isolation (or removing the '.concurrent' on the describe block above) - // fixes it. See CT-1094 for more details - test('should log the command if using static server and `command` is configured', async (t) => { - await withSiteBuilder(t, async (builder) => { - await builder - .withContentFile({ - path: 'public/index.html', - content, - }) - .build() - - await withDevServer( - { cwd: builder.directory, args: ['--dir', 'public', '--command', 'npm run start'] }, - async ({ output, url }) => { - const response = await fetch(url) - const responseContent = await response.text() - - t.expect(responseContent).toEqual(content) - t.expect(normalize(output, { duration: true, filePath: true })).toMatchSnapshot() - }, - ) - }) - }) - test('should warn if using static server and `targetPort` is configured', async (t) => { await withSiteBuilder(t, async (builder) => { await builder From 3b155b3133db747c6a7f99949dcb3519c89d1865 Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Tue, 7 May 2024 19:44:36 -0400 Subject: [PATCH 6/6] fix: clean up a few lint warnings --- src/utils/dev.ts | 11 +++++++++-- tests/integration/utils/site-builder.ts | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils/dev.ts b/src/utils/dev.ts index 912e46ce404..3b3859b799d 100644 --- a/src/utils/dev.ts +++ b/src/utils/dev.ts @@ -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}'`) diff --git a/tests/integration/utils/site-builder.ts b/tests/integration/utils/site-builder.ts index 88ff6018e91..4e719618d5f 100644 --- a/tests/integration/utils/site-builder.ts +++ b/tests/integration/utils/site-builder.ts @@ -11,13 +11,14 @@ import tomlify from 'tomlify-j0.4' import { v4 as uuidv4 } from 'uuid' import type { TaskContext } from 'vitest' -const ensureDir = (file) => mkdir(file, { recursive: true }) +const ensureDir = (directory: string) => mkdir(directory, { recursive: true }) type Task = () => Promise export class SiteBuilder { tasks: Task[] = [] + // eslint-disable-next-line no-useless-constructor constructor(public readonly directory: string) {} ensureDirectoryExists(directory: string) {