Skip to content

Commit e26e1f6

Browse files
committed
Reset simple proxy and try keep-alive to fix appveyor env issue
1 parent e59e460 commit e26e1f6

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

test/Client.test.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
'use strict';
22

3+
const express = require('express');
4+
const httpProxy = require('http-proxy-middleware');
35
const request = require('supertest');
46
const addEntries = require('../lib/utils/addEntries');
57
const helper = require('./helper');
68
const config = require('./fixtures/client-config/webpack.config');
79
const runBrowser = require('./helpers/run-browser');
810

9-
describe('Client code', () => {
10-
let server;
11+
function startProxy(port) {
12+
const proxy = express();
13+
proxy.use(
14+
'/',
15+
httpProxy({
16+
target: 'http://0.0.0.0:8080',
17+
ws: true,
18+
changeOrigin: true,
19+
proxyTimeout: 30000,
20+
headers: {
21+
Connection: 'keep-alive',
22+
},
23+
})
24+
);
25+
return proxy.listen(port);
26+
}
1127

28+
describe('Client code', () => {
1229
beforeAll((done) => {
1330
const options = {
1431
compress: true,
@@ -21,35 +38,22 @@ describe('Client code', () => {
2138
},
2239
};
2340
addEntries(config, options);
24-
server = helper.start(config, options, done);
41+
helper.start(config, options, done);
2542
});
2643

27-
afterAll((done) => {
28-
server.close(done);
29-
});
44+
afterAll(helper.close);
3045

3146
describe('behind a proxy', () => {
3247
let proxy;
3348

3449
jest.setTimeout(30000);
3550

36-
beforeAll((done) => {
37-
// Start dev server as proxy.
38-
proxy = helper.start(
39-
config,
40-
{
41-
port: 9000,
42-
host: 'localhost',
43-
proxy: {
44-
'/': 'http://0.0.0.0:8080',
45-
},
46-
},
47-
done
48-
);
51+
beforeAll(() => {
52+
proxy = startProxy(9000);
4953
});
5054

51-
afterAll((done) => {
52-
proxy.close(done);
55+
afterAll(() => {
56+
proxy.close();
5357
});
5458

5559
it('responds with a 200', (done) => {

0 commit comments

Comments
 (0)