Skip to content

Commit abeaa9c

Browse files
committed
test(open-option): fix test
1 parent c89d3c1 commit abeaa9c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/utils/runOpen.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ const open = require('opn');
44

55
function runOpen(uri, options, log) {
66
// https://github.com/webpack/webpack-dev-server/issues/1990
7-
const openOptions = { wait: false };
7+
let openOptions = { wait: false };
88
let openMessage = 'Unable to open browser';
99

1010
if (typeof options.open === 'string') {
11-
Object.assign(openOptions, {
12-
app: options.open,
13-
});
11+
openOptions = Object.assign({}, openOptions, { app: options.open });
1412
openMessage += `: ${options.open}`;
1513
}
1614

test/server/open-option.test.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ describe('open option', () => {
2121
});
2222

2323
compiler.hooks.done.tap('webpack-dev-server', () => {
24-
expect(opn.mock.calls[0]).toEqual(['http://localhost:8080/', {}]);
25-
expect(opn.mock.invocationCallOrder[0]).toEqual(1);
26-
server.close(done);
24+
server.close(() => {
25+
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
26+
Array [
27+
"http://localhost:8080/",
28+
Object {
29+
"wait": false,
30+
},
31+
]
32+
`);
33+
expect(opn.mock.invocationCallOrder[0]).toEqual(1);
34+
done();
35+
});
2736
});
2837

2938
compiler.run(() => {});

0 commit comments

Comments
 (0)