Skip to content

Commit

Permalink
test(client): check console.log (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy authored and evilebottnawi committed May 29, 2019
1 parent f6bfedb commit bc83223
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/Client.test.js
Expand Up @@ -229,3 +229,71 @@ describe('Client complex inline script path with sockHost', () => {
});
});
});

describe('Client console.log', () => {
jest.setTimeout(30000);

const baseOptions = {
port: 9000,
host: '0.0.0.0',
};
const cases = [
{
title: 'hot disabled',
options: {
hot: false,
},
},
{
title: 'hot enabled',
options: {
hot: true,
},
},
{
title: 'liveReload disabled',
options: {
liveReload: false,
},
},
{
title: 'liveReload enabled',
options: {
liveReload: true,
},
},
];

for (const { title, options } of cases) {
it(title, () => {
const res = [];
const testOptions = Object.assign({}, baseOptions, options);

// TODO: use async/await when Node.js v6 support is dropped
return Promise.resolve()
.then(() => {
return new Promise((resolve) => {
testServer.startAwaitingCompilation(config, testOptions, resolve);
});
})
.then(runBrowser)
.then(({ page, browser }) => {
return new Promise((resolve) => {
page.goto('http://localhost:9000/main');
page.on('console', ({ _text }) => {
res.push(_text);
});
setTimeout(() => {
expect(res).toMatchSnapshot();
browser.close().then(resolve);
}, 3000);
});
})
.then(() => {
return new Promise((resolve) => {
testServer.close(resolve);
});
});
});
}
});
29 changes: 29 additions & 0 deletions test/__snapshots__/Client.test.js.snap
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Client console.log hot disabled 1`] = `
Array [
"Hey.",
"[WDS] Live Reloading enabled.",
]
`;

exports[`Client console.log hot enabled 1`] = `
Array [
"[HMR] Waiting for update signal from WDS...",
"Hey.",
"[WDS] Hot Module Replacement enabled.",
"[WDS] Live Reloading enabled.",
]
`;

exports[`Client console.log liveReload disabled 1`] = `
Array [
"Hey.",
]
`;

exports[`Client console.log liveReload enabled 1`] = `
Array [
"Hey.",
]
`;

0 comments on commit bc83223

Please sign in to comment.