Skip to content

Commit dc54244

Browse files
test: stability
1 parent 0574539 commit dc54244

3 files changed

Lines changed: 32 additions & 29 deletions

File tree

src/middleware.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ function wrapper(context) {
876876
// Error handling
877877
/** @type {import("fs").ReadStream} */
878878
(bufferOrStream).on("error", (error) => {
879+
context.logger.error("Stream error:", error);
879880
// clean up stream early
880881
cleanup();
881882
errorHandler(error);

test/fixtures/webpack.array.dev-server-false.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = [
1010
output: {
1111
filename: 'bundle.js',
1212
path: path.resolve(__dirname, '../outputs/dev-server-false/js3'),
13-
publicPath: '/static-two/',
13+
publicPath: '/static-one/',
1414
},
1515
infrastructureLogging: {
1616
level: 'none'
@@ -25,7 +25,7 @@ module.exports = [
2525
output: {
2626
filename: 'bundle.js',
2727
path: path.resolve(__dirname, '../outputs/dev-server-false/js4'),
28-
publicPath: '/static-one/',
28+
publicPath: '/static-two/',
2929
},
3030
module: {
3131
rules: [

test/middleware.test.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,19 +1450,20 @@ describe.each([
14501450
await close(server, instance);
14511451
});
14521452

1453-
it('should return "200" code for GET request to the bundle file for the first compiler', async () => {
1453+
it('should return "404" code for GET request to the bundle file for the first compiler', async () => {
14541454
const bundlePath = path.resolve(
14551455
__dirname,
1456-
"./outputs/dev-server-false/js4/",
1457-
);
1458-
1459-
expect(fs.existsSync(path.resolve(bundlePath, "bundle.js"))).toBe(
1460-
false,
1456+
"./outputs/dev-server-false/js3/",
14611457
);
14621458

14631459
const response = await req.get("/static-one/bundle.js");
14641460

1465-
expect(response.statusCode).toBe(200);
1461+
expect(response.statusCode).toBe(404);
1462+
1463+
// Stored in the real fs
1464+
expect(fs.existsSync(path.resolve(bundlePath, "bundle.js"))).toBe(
1465+
true,
1466+
);
14661467
});
14671468

14681469
it('should return "404" code for GET request to a non existing file for the first compiler', async () => {
@@ -1471,37 +1472,32 @@ describe.each([
14711472
expect(response.statusCode).toBe(404);
14721473
});
14731474

1474-
it('should return "200" code for GET request to the "public" path for the first compiler', async () => {
1475+
it('should return "404" code for GET request to the "public" path for the first compiler', async () => {
14751476
const response = await req.get("/static-one/");
14761477

1477-
expect(response.statusCode).toBe(200);
1478-
expect(response.headers["content-type"]).toBe(
1479-
"text/html; charset=utf-8",
1480-
);
1478+
expect(response.statusCode).toBe(404);
14811479
});
14821480

1483-
it('should return "200" code for GET request to the "index" option for the first compiler', async () => {
1481+
it('should return "404" code for GET request to the "index" option for the first compiler', async () => {
14841482
const response = await req.get("/static-one/index.html");
14851483

1486-
expect(response.statusCode).toBe(200);
1487-
expect(response.headers["content-type"]).toBe(
1488-
"text/html; charset=utf-8",
1489-
);
1484+
expect(response.statusCode).toBe(404);
14901485
});
14911486

14921487
it('should return "200" code for GET request for the bundle file for the second compiler', async () => {
14931488
const bundlePath = path.resolve(
14941489
__dirname,
1495-
"./outputs/dev-server-false/js3/",
1496-
);
1497-
1498-
expect(fs.existsSync(path.resolve(bundlePath, "bundle.js"))).toBe(
1499-
true,
1490+
"./outputs/dev-server-false/js4/",
15001491
);
15011492

15021493
const response = await req.get("/static-two/bundle.js");
15031494

1504-
expect(response.statusCode).toBe(404);
1495+
expect(response.statusCode).toBe(200);
1496+
1497+
// stored in memory
1498+
expect(fs.existsSync(path.resolve(bundlePath, "bundle.js"))).toBe(
1499+
false,
1500+
);
15051501
});
15061502

15071503
it('should return "404" code for GET request to a non existing file for the second compiler', async () => {
@@ -1510,16 +1506,22 @@ describe.each([
15101506
expect(response.statusCode).toBe(404);
15111507
});
15121508

1513-
it('should return "404" code for GET request to the "public" path for the second compiler', async () => {
1509+
it('should return "200" code for GET request to the "public" path for the second compiler', async () => {
15141510
const response = await req.get("/static-two/");
15151511

1516-
expect(response.statusCode).toBe(404);
1512+
expect(response.statusCode).toBe(200);
1513+
expect(response.headers["content-type"]).toBe(
1514+
"text/html; charset=utf-8",
1515+
);
15171516
});
15181517

1519-
it('should return "404" code for GET request to the "index" option for the second compiler', async () => {
1518+
it('should return "200" code for GET request to the "index" option for the second compiler', async () => {
15201519
const response = await req.get("/static-two/index.html");
15211520

1522-
expect(response.statusCode).toBe(404);
1521+
expect(response.statusCode).toBe(200);
1522+
expect(response.headers["content-type"]).toBe(
1523+
"text/html; charset=utf-8",
1524+
);
15231525
});
15241526

15251527
it('should return "404" code for GET request to the non-public path', async () => {

0 commit comments

Comments
 (0)