-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Progress.test.js
64 lines (57 loc) · 1.69 KB
/
Progress.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
/* eslint-disable
no-undef
*/
const fs = require('fs');
const { resolve } = require('path');
const testServer = require('../helpers/test-server');
const reloadConfig = require('../fixtures/reload-config/webpack.config');
const runBrowser = require('../helpers/run-browser');
const cssFilePath = resolve(__dirname, '../fixtures/reload-config/main.css');
describe('client progress', () => {
describe('using hot', () => {
beforeAll((done) => {
fs.writeFileSync(
cssFilePath,
'body { background-color: rgb(0, 0, 255); }'
);
const options = {
port: 9000,
host: '0.0.0.0',
inline: true,
hot: true,
progress: true,
watchOptions: {
poll: 500,
},
};
testServer.startAwaitingCompilation(reloadConfig, options, done);
});
afterAll((done) => {
testServer.close(done);
});
describe('on browser client', () => {
jest.setTimeout(30000);
it('should console.log progress', (done) => {
runBrowser().then(({ page, browser }) => {
const res = [];
page.waitForNavigation({ waitUntil: 'load' }).then(() => {
fs.writeFileSync(
cssFilePath,
'body { background-color: rgb(255, 0, 0); }'
);
page.waitFor(10000).then(() => {
expect(res.includes('[WDS] 0% - compiling.')).toBeTruthy();
fs.unlinkSync(cssFilePath);
browser.close().then(done);
});
});
page.goto('http://localhost:9000/main');
page.on('console', ({ _text }) => {
res.push(_text);
});
});
});
});
});
});