/
UniversalCompiler.test.js
48 lines (43 loc) · 1.35 KB
/
UniversalCompiler.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
'use strict';
const request = require('supertest');
const helper = require('./helper');
const config = require('./fixtures/universal-compiler-config/webpack.config');
describe('UniversalCompiler', () => {
let server;
let req;
beforeAll((done) => {
server = helper.start(config, { inline: true }, done);
req = request(server.app);
});
afterAll(helper.close);
it('client bundle should have the inlined the client runtime', (done) => {
req
.get('/client.js')
.expect('Content-Type', 'application/javascript; charset=UTF-8')
.expect(200)
.end((err, res) => {
if (err) {
return done(err);
}
expect(res.text).toContain('Hello from the client');
expect(res.text).toContain('webpack-dev-server/client');
done();
});
});
it('server bundle should NOT have the inlined the client runtime', (done) => {
// we wouldn't normally request a server bundle
// but we'll do it here to check the contents
req
.get('/server.js')
.expect('Content-Type', 'application/javascript; charset=UTF-8')
.expect(200)
.end((err, res) => {
if (err) {
return done(err);
}
expect(res.text).toContain('Hello from the server');
expect(res.text).not.toContain('webpack-dev-server/client');
done();
});
});
});