Skip to content

Commit 807c5b5

Browse files
authored
test: migrate bonjour tests to e2e (#3200)
1 parent 5e93941 commit 807c5b5

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

test/ports-map.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const portsList = {
4545
ModuleFederation: 1,
4646
'setupExitSignals-option': 1,
4747
'watchFiles-option': 1,
48+
bonjour: 1,
4849
};
4950

5051
let startPort = 8089;

test/server/bonjour-option.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
const os = require('os');
4+
const config = require('../fixtures/simple-config/webpack.config');
5+
const testServer = require('../helpers/test-server');
6+
const port = require('../ports-map').bonjour;
7+
8+
describe('bonjour option', () => {
9+
let server;
10+
const mockPublish = jest.fn();
11+
const mockUnpublishAll = jest.fn();
12+
13+
beforeAll(() => {
14+
jest.mock('bonjour', () => () => {
15+
return {
16+
publish: mockPublish,
17+
unpublishAll: mockUnpublishAll,
18+
};
19+
});
20+
});
21+
22+
beforeEach((done) => {
23+
server = testServer.start(
24+
config,
25+
{
26+
bonjour: true,
27+
port,
28+
},
29+
done
30+
);
31+
});
32+
33+
afterEach((done) => {
34+
mockPublish.mockReset();
35+
mockUnpublishAll.mockReset();
36+
server.close(done);
37+
});
38+
39+
it('should call bonjour with correct params', () => {
40+
expect(mockPublish).toHaveBeenCalledTimes(1);
41+
expect(mockPublish).toHaveBeenCalledWith({
42+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
43+
port,
44+
type: 'http',
45+
subtypes: ['webpack'],
46+
});
47+
expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
48+
});
49+
});

test/server/utils/runBonjour.test.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)