Skip to content

Commit c049129

Browse files
committed
fix: static-directory.test.js flaky test-case
1 parent ecb160a commit c049129

File tree

33 files changed

+24
-107
lines changed

33 files changed

+24
-107
lines changed

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-defaults-to-PWD-should-handle-request-to-index-html-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-defaults-to-PWD-should-handle-request-to-index-html-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-disabled-should-not-handle-request-to-other-html-404-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-disabled-should-not-handle-request-to-other-html-404-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-default-static-serveIndex-option-true-should-list-the-files-inside-the-assets-folder-200-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-default-static-serveIndex-option-true-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-default-static-serveIndex-option-true-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-false-should-not-list-the-files-inside-the-assets-folder-404-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-false-should-not-list-the-files-inside-the-assets-folder-404-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-false-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-false-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-true-should-list-the-files-inside-the-assets-folder-200-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-true-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-test-listing-files-in-folders-without-index-html-using-the-option-static-serveIndex-true-should-show-Heyo-because-bar-has-index-html-inside-it-200-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-directory-should-handle-request-to-index-route-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-directory-should-handle-request-to-index-route-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-directory-should-handle-request-to-other-file-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-directory-should-handle-request-to-other-file-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-multiple-directories-should-handle-request-first-directory-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-multiple-directories-should-handle-request-first-directory-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-multiple-directories-should-handle-request-to-second-directory-response-status-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/__snapshots__/static-directory.test.js/static-directory-option-to-multiple-directories-should-handle-request-to-second-directory-response-text-snap.webpack5

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/static-directory.test.js

Lines changed: 23 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ test.describe("static.directory option", () => {
593593

594594
test.afterEach(async () => {
595595
await server.stop();
596+
process.cwd.restore();
596597
});
597598

598599
test("should handle request to /index.html", async ({ page }) => {
@@ -620,63 +621,7 @@ test.describe("static.directory option", () => {
620621
});
621622
});
622623

623-
// FIXME: check the below error
624-
// TypeError: Attempted to wrap cwd which is already wrapped
625-
// TypeError: Cannot read properties of undefined (reading 'stop')
626-
//
627-
// at checkWrappedMethod (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/util/core/wrap-method.js:67:21)
628-
// at wrapMethod (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/util/core/wrap-method.js:132:13)
629-
// at Function.stub (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/stub.js:130:44)
630-
// at Sandbox.stub (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/sandbox.js:454:39)
631-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/test/e2e/static-directory.test.js:617:13
632-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/fixtureRunner.js:254:13
633-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:17
634-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:53:34)
635-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:34)
636-
// at FixtureRunner.resolveParametersAndRunFunction (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/fixtureRunner.js:250:20)
637-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:588:11
638-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
639-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
640-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
641-
// at WorkerMain._runEachHooksForSuites (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:576:9)
642-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:317:9
643-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
644-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
645-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
646-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:306:7
647-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
648-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
649-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
650-
// at WorkerMain._runTest (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:278:5)
651-
// at WorkerMain.runTestGroup (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:202:11)
652-
// at process.<anonymous> (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/common/process.js:94:22)
653-
// at extendObjectWithWrappedMethods (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/util/core/wrap-method.js:173:34)
654-
// at wrapMethod (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/util/core/wrap-method.js:161:5)
655-
// at Function.stub (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/stub.js:130:44)
656-
// at Sandbox.stub (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/sinon/lib/sinon/sandbox.js:454:39)
657-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/test/e2e/static-directory.test.js:561:13
658-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/fixtureRunner.js:254:13
659-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:17
660-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:53:34)
661-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:34)
662-
// at FixtureRunner.resolveParametersAndRunFunction (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/fixtureRunner.js:250:20)
663-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:588:11
664-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
665-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
666-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
667-
// at WorkerMain._runEachHooksForSuites (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:576:9)
668-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:317:9
669-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
670-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
671-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
672-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:306:7
673-
// at /Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:297:11
674-
// at TimeoutManager.withRunnable (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/timeoutManager.js:41:27)
675-
// at TestInfoImpl._runAsStage (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/testInfo.js:295:7)
676-
// at WorkerMain._runTest (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:278:5)
677-
// at WorkerMain.runTestGroup (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/worker/workerMain.js:202:11)
678-
// at process.<anonymous> (/Users/mahdi/tmp/webpack-dev-server/test/fixtures/static-config/node_modules/playwright/lib/common/process.js:94:22)
679-
test.describe.fixme("disabled", () => {
624+
test.describe("disabled", () => {
680625
let compiler;
681626
let server;
682627
let pageErrors;
@@ -685,8 +630,7 @@ test.describe("static.directory option", () => {
685630
test.beforeEach(async () => {
686631
// This is a somewhat weird test, but it is important that we mock
687632
// the PWD here, and test if /other.html in our "fake" PWD really is not requested.
688-
sinon.stub(process, "cwd").callsFake(() => publicDirectory);
689-
633+
sinon.stub(process, "cwd").callsFake(() => path.resolve(publicDirectory));
690634
compiler = webpack(config);
691635

692636
server = new Server(
@@ -705,37 +649,31 @@ test.describe("static.directory option", () => {
705649

706650
test.afterEach(async () => {
707651
await server.stop();
652+
process.cwd.restore();
708653
});
709654

710-
test(
711-
"should not handle request to /other.html (404)",
712-
{ tags: "@flaky" },
713-
async ({ page }) => {
714-
page
715-
.on("console", (message) => {
716-
consoleMessages.push(message);
717-
})
718-
.on("pageerror", (error) => {
719-
pageErrors.push(error);
720-
});
721-
722-
const response = await page.goto(
723-
`http://127.0.0.1:${port}/index.html`,
724-
{
725-
waitUntil: "networkidle0",
726-
},
727-
);
655+
test("should not handle request to /other.html (404)", async ({ page }) => {
656+
page
657+
.on("console", (message) => {
658+
consoleMessages.push(message);
659+
})
660+
.on("pageerror", (error) => {
661+
pageErrors.push(error);
662+
});
728663

729-
expect(response.status()).toBe(200);
664+
const response = await page.goto(`http://127.0.0.1:${port}/index.html`, {
665+
waitUntil: "networkidle0",
666+
});
730667

731-
await expect(page).toHaveScreenshot();
668+
expect(response.status()).toBe(404);
732669

733-
expect(
734-
consoleMessages.map((message) => message.text()),
735-
).toMatchSnapshotWithArray("console messages");
670+
await expect(page).toHaveScreenshot();
736671

737-
expect(pageErrors).toMatchSnapshotWithArray("page errors");
738-
},
739-
);
672+
expect(
673+
consoleMessages.map((message) => message.text()),
674+
).toMatchSnapshotWithArray("console messages");
675+
676+
expect(pageErrors).toMatchSnapshotWithArray("page errors");
677+
});
740678
});
741679
});

test/fixtures/static-config/public/node_modules/index.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)