Skip to content

Commit bc83223

Browse files
hiroppyevilebottnawi
authored andcommitted
test(client): check console.log (#1907)
1 parent f6bfedb commit bc83223

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

test/Client.test.js

+68
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,71 @@ describe('Client complex inline script path with sockHost', () => {
229229
});
230230
});
231231
});
232+
233+
describe('Client console.log', () => {
234+
jest.setTimeout(30000);
235+
236+
const baseOptions = {
237+
port: 9000,
238+
host: '0.0.0.0',
239+
};
240+
const cases = [
241+
{
242+
title: 'hot disabled',
243+
options: {
244+
hot: false,
245+
},
246+
},
247+
{
248+
title: 'hot enabled',
249+
options: {
250+
hot: true,
251+
},
252+
},
253+
{
254+
title: 'liveReload disabled',
255+
options: {
256+
liveReload: false,
257+
},
258+
},
259+
{
260+
title: 'liveReload enabled',
261+
options: {
262+
liveReload: true,
263+
},
264+
},
265+
];
266+
267+
for (const { title, options } of cases) {
268+
it(title, () => {
269+
const res = [];
270+
const testOptions = Object.assign({}, baseOptions, options);
271+
272+
// TODO: use async/await when Node.js v6 support is dropped
273+
return Promise.resolve()
274+
.then(() => {
275+
return new Promise((resolve) => {
276+
testServer.startAwaitingCompilation(config, testOptions, resolve);
277+
});
278+
})
279+
.then(runBrowser)
280+
.then(({ page, browser }) => {
281+
return new Promise((resolve) => {
282+
page.goto('http://localhost:9000/main');
283+
page.on('console', ({ _text }) => {
284+
res.push(_text);
285+
});
286+
setTimeout(() => {
287+
expect(res).toMatchSnapshot();
288+
browser.close().then(resolve);
289+
}, 3000);
290+
});
291+
})
292+
.then(() => {
293+
return new Promise((resolve) => {
294+
testServer.close(resolve);
295+
});
296+
});
297+
});
298+
}
299+
});
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Client console.log hot disabled 1`] = `
4+
Array [
5+
"Hey.",
6+
"[WDS] Live Reloading enabled.",
7+
]
8+
`;
9+
10+
exports[`Client console.log hot enabled 1`] = `
11+
Array [
12+
"[HMR] Waiting for update signal from WDS...",
13+
"Hey.",
14+
"[WDS] Hot Module Replacement enabled.",
15+
"[WDS] Live Reloading enabled.",
16+
]
17+
`;
18+
19+
exports[`Client console.log liveReload disabled 1`] = `
20+
Array [
21+
"Hey.",
22+
]
23+
`;
24+
25+
exports[`Client console.log liveReload enabled 1`] = `
26+
Array [
27+
"Hey.",
28+
]
29+
`;

0 commit comments

Comments
 (0)