Skip to content

Commit 3916661

Browse files
authored
test(helpers): rename to run-bin and run-server (#1908)
1 parent 23ac25c commit 3916661

24 files changed

+401
-277
lines changed

test/BeforeAndAfter.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

33
const request = require('supertest');
4-
const helper = require('./helper');
4+
const testServer = require('./helpers/test-server');
55
const config = require('./fixtures/simple-config/webpack.config');
66

77
describe('Before And After options', () => {
88
let server;
99
let req;
1010

1111
beforeAll((done) => {
12-
server = helper.start(
12+
server = testServer.start(
1313
config,
1414
{
1515
before: (appArg, serverArg, compilerArg) => {
@@ -52,7 +52,7 @@ describe('Before And After options', () => {
5252
req = request(server.app);
5353
});
5454

55-
afterAll(helper.close);
55+
afterAll(testServer.close);
5656

5757
it('should handle before route', () => {
5858
return req

test/Client.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const express = require('express');
44
const httpProxy = require('http-proxy-middleware');
55
const request = require('supertest');
6-
const helper = require('./helper');
6+
const testServer = require('./helpers/test-server');
77
const config = require('./fixtures/client-config/webpack.config');
88
const runBrowser = require('./helpers/run-browser');
99

@@ -33,10 +33,10 @@ describe('Client code', () => {
3333
poll: true,
3434
},
3535
};
36-
helper.startAwaitingCompilation(config, options, done);
36+
testServer.startAwaitingCompilation(config, options, done);
3737
});
3838

39-
afterAll(helper.close);
39+
afterAll(testServer.close);
4040

4141
// [HPM] Proxy created: / -> http://localhost:9001
4242
describe('behind a proxy', () => {
@@ -93,10 +93,10 @@ describe('Client complex inline script path', () => {
9393
public: 'myhost.test',
9494
sockPath: '/foo/test/bar/',
9595
};
96-
helper.startAwaitingCompilation(config, options, done);
96+
testServer.startAwaitingCompilation(config, options, done);
9797
});
9898

99-
afterAll(helper.close);
99+
afterAll(testServer.close);
100100

101101
describe('browser client', () => {
102102
jest.setTimeout(30000);
@@ -131,10 +131,10 @@ describe('Client complex inline script path with sockPort', () => {
131131
sockPath: '/foo/test/bar/',
132132
sockPort: 8080,
133133
};
134-
helper.startAwaitingCompilation(config, options, done);
134+
testServer.startAwaitingCompilation(config, options, done);
135135
});
136136

137-
afterAll(helper.close);
137+
afterAll(testServer.close);
138138

139139
describe('browser client', () => {
140140
jest.setTimeout(30000);
@@ -171,10 +171,10 @@ describe('Client complex inline script path with sockPort, no sockPath', () => {
171171
},
172172
sockPort: 8080,
173173
};
174-
helper.startAwaitingCompilation(config, options, done);
174+
testServer.startAwaitingCompilation(config, options, done);
175175
});
176176

177-
afterAll(helper.close);
177+
afterAll(testServer.close);
178178

179179
describe('browser client', () => {
180180
jest.setTimeout(30000);
@@ -206,10 +206,10 @@ describe('Client complex inline script path with sockHost', () => {
206206
},
207207
sockHost: 'myhost.test',
208208
};
209-
helper.startAwaitingCompilation(config, options, done);
209+
testServer.startAwaitingCompilation(config, options, done);
210210
});
211211

212-
afterAll(helper.close);
212+
afterAll(testServer.close);
213213

214214
describe('browser client', () => {
215215
jest.setTimeout(30000);

test/Compress.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'use strict';
77

88
const request = require('supertest');
9-
const helper = require('./helper');
9+
const testServer = require('./helpers/test-server');
1010
const config = require('./fixtures/simple-config-other/webpack.config');
1111

1212
describe('Compress', () => {
@@ -15,11 +15,11 @@ describe('Compress', () => {
1515

1616
describe('undefined', () => {
1717
beforeAll((done) => {
18-
server = helper.start(config, {}, done);
18+
server = testServer.start(config, {}, done);
1919
req = request(server.app);
2020
});
2121

22-
afterAll(helper.close);
22+
afterAll(testServer.close);
2323

2424
it('request to bundle file', (done) => {
2525
req
@@ -35,7 +35,7 @@ describe('Compress', () => {
3535

3636
describe('true', () => {
3737
beforeAll((done) => {
38-
server = helper.start(
38+
server = testServer.start(
3939
config,
4040
{
4141
compress: true,
@@ -45,7 +45,7 @@ describe('Compress', () => {
4545
req = request(server.app);
4646
});
4747

48-
afterAll(helper.close);
48+
afterAll(testServer.close);
4949

5050
it('request to bundle file', (done) => {
5151
req
@@ -57,7 +57,7 @@ describe('Compress', () => {
5757

5858
describe('false', () => {
5959
beforeAll((done) => {
60-
server = helper.start(
60+
server = testServer.start(
6161
config,
6262
{
6363
compress: false,
@@ -67,7 +67,7 @@ describe('Compress', () => {
6767
req = request(server.app);
6868
});
6969

70-
afterAll(helper.close);
70+
afterAll(testServer.close);
7171

7272
it('request to bundle file', (done) => {
7373
req

test/ContentBase.test.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require('path');
44
const fs = require('fs');
55
const request = require('supertest');
6-
const helper = require('./helper');
6+
const testServer = require('./helpers/test-server');
77
const config = require('./fixtures/contentbase-config/webpack.config');
88

99
const contentBasePublic = path.join(
@@ -25,7 +25,7 @@ describe('ContentBase', () => {
2525
jest.setTimeout(30000);
2626

2727
beforeAll((done) => {
28-
server = helper.start(
28+
server = testServer.start(
2929
config,
3030
{
3131
contentBase: contentBasePublic,
@@ -37,7 +37,7 @@ describe('ContentBase', () => {
3737
});
3838

3939
afterAll((done) => {
40-
helper.close(() => {
40+
testServer.close(() => {
4141
done();
4242
});
4343
fs.truncateSync(nestedFile);
@@ -69,7 +69,7 @@ describe('ContentBase', () => {
6969
jest.setTimeout(30000);
7070

7171
beforeAll((done) => {
72-
server = helper.start(config, {
72+
server = testServer.start(config, {
7373
contentBase: contentBasePublic,
7474
watchContentBase: true,
7575
});
@@ -81,7 +81,7 @@ describe('ContentBase', () => {
8181
});
8282

8383
afterAll((done) => {
84-
helper.close(() => {
84+
testServer.close(() => {
8585
done();
8686
});
8787
});
@@ -106,7 +106,7 @@ describe('ContentBase', () => {
106106
jest.setTimeout(30000);
107107

108108
beforeAll((done) => {
109-
server = helper.start(config, {
109+
server = testServer.start(config, {
110110
contentBase: contentBasePublic,
111111
watchContentBase: true,
112112
watchOptions: {
@@ -121,7 +121,7 @@ describe('ContentBase', () => {
121121
});
122122

123123
afterAll((done) => {
124-
helper.close(() => {
124+
testServer.close(() => {
125125
done();
126126
});
127127
});
@@ -141,7 +141,7 @@ describe('ContentBase', () => {
141141

142142
describe('test listing files in folders without index.html using the option serveIndex:false', () => {
143143
beforeAll((done) => {
144-
server = helper.start(
144+
server = testServer.start(
145145
config,
146146
{
147147
contentBase: contentBasePublic,
@@ -154,7 +154,7 @@ describe('ContentBase', () => {
154154
});
155155

156156
afterAll((done) => {
157-
helper.close(() => {
157+
testServer.close(() => {
158158
done();
159159
});
160160
});
@@ -169,7 +169,7 @@ describe('ContentBase', () => {
169169
});
170170
describe('test listing files in folders without index.html using the option serveIndex:true', () => {
171171
beforeAll((done) => {
172-
server = helper.start(
172+
server = testServer.start(
173173
config,
174174
{
175175
contentBase: contentBasePublic,
@@ -182,7 +182,7 @@ describe('ContentBase', () => {
182182
});
183183

184184
afterAll((done) => {
185-
helper.close(() => {
185+
testServer.close(() => {
186186
done();
187187
});
188188
});
@@ -197,7 +197,7 @@ describe('ContentBase', () => {
197197
});
198198
describe('test listing files in folders without index.html using the option serveIndex default (true)', () => {
199199
beforeAll((done) => {
200-
server = helper.start(
200+
server = testServer.start(
201201
config,
202202
{
203203
contentBase: contentBasePublic,
@@ -209,7 +209,7 @@ describe('ContentBase', () => {
209209
});
210210

211211
afterAll((done) => {
212-
helper.close(() => {
212+
testServer.close(() => {
213213
done();
214214
});
215215
});
@@ -224,7 +224,7 @@ describe('ContentBase', () => {
224224
});
225225
describe('to directories', () => {
226226
beforeAll((done) => {
227-
server = helper.start(
227+
server = testServer.start(
228228
config,
229229
{
230230
contentBase: [contentBasePublic, contentBaseOther],
@@ -235,7 +235,7 @@ describe('ContentBase', () => {
235235
});
236236

237237
afterAll((done) => {
238-
helper.close(() => {
238+
testServer.close(() => {
239239
done();
240240
});
241241
});
@@ -251,7 +251,7 @@ describe('ContentBase', () => {
251251

252252
describe('to port', () => {
253253
beforeAll((done) => {
254-
server = helper.start(
254+
server = testServer.start(
255255
config,
256256
{
257257
contentBase: 9099999,
@@ -262,7 +262,7 @@ describe('ContentBase', () => {
262262
});
263263

264264
afterAll((done) => {
265-
helper.close(() => {
265+
testServer.close(() => {
266266
done();
267267
});
268268
});
@@ -277,7 +277,7 @@ describe('ContentBase', () => {
277277

278278
describe('to external url', () => {
279279
beforeAll((done) => {
280-
server = helper.start(
280+
server = testServer.start(
281281
config,
282282
{
283283
contentBase: 'http://example.com/',
@@ -288,7 +288,7 @@ describe('ContentBase', () => {
288288
});
289289

290290
afterAll((done) => {
291-
helper.close(() => {
291+
testServer.close(() => {
292292
done();
293293
});
294294
});
@@ -313,12 +313,12 @@ describe('ContentBase', () => {
313313
describe('default to PWD', () => {
314314
beforeAll((done) => {
315315
jest.spyOn(process, 'cwd').mockImplementation(() => contentBasePublic);
316-
server = helper.start(config, {}, done);
316+
server = testServer.start(config, {}, done);
317317
req = request(server.app);
318318
});
319319

320320
afterAll((done) => {
321-
helper.close(() => {
321+
testServer.close(() => {
322322
done();
323323
});
324324
});
@@ -333,7 +333,7 @@ describe('ContentBase', () => {
333333
// This is a somewhat weird test, but it is important that we mock
334334
// the PWD here, and test if /other.html in our "fake" PWD really is not requested.
335335
jest.spyOn(process, 'cwd').mockImplementation(() => contentBasePublic);
336-
server = helper.start(
336+
server = testServer.start(
337337
config,
338338
{
339339
contentBase: false,
@@ -344,7 +344,7 @@ describe('ContentBase', () => {
344344
});
345345

346346
afterAll((done) => {
347-
helper.close(() => {
347+
testServer.close(() => {
348348
done();
349349
});
350350
});
@@ -356,7 +356,7 @@ describe('ContentBase', () => {
356356

357357
describe('Content type', () => {
358358
beforeAll((done) => {
359-
server = helper.start(
359+
server = testServer.start(
360360
config,
361361
{
362362
contentBase: [contentBasePublic],
@@ -367,7 +367,7 @@ describe('ContentBase', () => {
367367
});
368368

369369
afterAll((done) => {
370-
helper.close(() => {
370+
testServer.close(() => {
371371
done();
372372
});
373373
});

0 commit comments

Comments
 (0)