Skip to content

Commit df725db

Browse files
authored
test: replace webpack with rspack in test files (#93)
1 parent 87e1332 commit df725db

36 files changed

Lines changed: 290 additions & 290 deletions

tests/e2e/allowed-hosts.test.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const express = require('express');
2-
const webpack = require('@rspack/core');
2+
const { rspack } = require('@rspack/core');
33
const { createProxyMiddleware } = require('http-proxy-middleware');
44
const { RspackDevServer: Server } = require('@rspack/dev-server');
55
const config = require('../fixtures/client-config/webpack.config');
@@ -16,7 +16,7 @@ describe('allowed hosts', () => {
1616
const proxyHost = devServerHost;
1717
const proxyPort = port2;
1818

19-
const compiler = webpack(config);
19+
const compiler = rspack(config);
2020
const devServerOptions = {
2121
client: {
2222
webSocketURL: {
@@ -89,7 +89,7 @@ describe('allowed hosts', () => {
8989
const proxyHost = devServerHost;
9090
const proxyPort = port2;
9191

92-
const compiler = webpack(config);
92+
const compiler = rspack(config);
9393
const devServerOptions = {
9494
client: {
9595
webSocketURL: {
@@ -162,7 +162,7 @@ describe('allowed hosts', () => {
162162
const proxyHost = devServerHost;
163163
const proxyPort = port2;
164164

165-
const compiler = webpack(config);
165+
const compiler = rspack(config);
166166
const devServerOptions = {
167167
client: {
168168
webSocketURL: {
@@ -235,7 +235,7 @@ describe('allowed hosts', () => {
235235
const proxyHost = devServerHost;
236236
const proxyPort = port2;
237237

238-
const compiler = webpack(config);
238+
const compiler = rspack(config);
239239
const devServerOptions = {
240240
client: {
241241
webSocketURL: {
@@ -309,7 +309,7 @@ describe('allowed hosts', () => {
309309
const proxyHost = devServerHost;
310310
const proxyPort = port2;
311311

312-
const compiler = webpack(config);
312+
const compiler = rspack(config);
313313
const devServerOptions = {
314314
client: {
315315
webSocketURL: {
@@ -384,7 +384,7 @@ describe('allowed hosts', () => {
384384
const proxyHost = IPv4;
385385
const proxyPort = port2;
386386

387-
const compiler = webpack(config);
387+
const compiler = rspack(config);
388388
const devServerOptions = {
389389
client: {
390390
webSocketURL: {
@@ -458,7 +458,7 @@ describe('allowed hosts', () => {
458458
const proxyHost = devServerHost;
459459
const proxyPort = port2;
460460

461-
const compiler = webpack(config);
461+
const compiler = rspack(config);
462462
const devServerOptions = {
463463
client: {
464464
webSocketURL: {
@@ -535,7 +535,7 @@ describe('allowed hosts', () => {
535535
const proxyHost = devServerHost;
536536
const proxyPort = port2;
537537

538-
const compiler = webpack(config);
538+
const compiler = rspack(config);
539539
const devServerOptions = {
540540
client: {
541541
webSocketURL: {
@@ -612,7 +612,7 @@ describe('allowed hosts', () => {
612612
const proxyHost = devServerHost;
613613
const proxyPort = port2;
614614

615-
const compiler = webpack(config);
615+
const compiler = rspack(config);
616616
const devServerOptions = {
617617
client: {
618618
webSocketURL: {
@@ -690,7 +690,7 @@ describe('allowed hosts', () => {
690690
const proxyHost = devServerHost;
691691
const proxyPort = port2;
692692

693-
const compiler = webpack(config);
693+
const compiler = rspack(config);
694694
const devServerOptions = {
695695
client: {
696696
webSocketURL: {
@@ -768,7 +768,7 @@ describe('allowed hosts', () => {
768768
const proxyHost = devServerHost;
769769
const proxyPort = port2;
770770

771-
const compiler = webpack(config);
771+
const compiler = rspack(config);
772772
const devServerOptions = {
773773
client: {
774774
webSocketURL: {
@@ -846,7 +846,7 @@ describe('allowed hosts', () => {
846846
const proxyHost = devServerHost;
847847
const proxyPort = port2;
848848

849-
const compiler = webpack(config);
849+
const compiler = rspack(config);
850850
const devServerOptions = {
851851
client: {
852852
webSocketURL: {
@@ -924,7 +924,7 @@ describe('allowed hosts', () => {
924924
const proxyHost = devServerHost;
925925
const proxyPort = port2;
926926

927-
const compiler = webpack(config);
927+
const compiler = rspack(config);
928928
const devServerOptions = {
929929
client: {
930930
webSocketURL: {
@@ -1005,7 +1005,7 @@ describe('allowed hosts', () => {
10051005
const proxyHost = devServerHost;
10061006
const proxyPort = port2;
10071007

1008-
const compiler = webpack(config);
1008+
const compiler = rspack(config);
10091009
const devServerOptions = {
10101010
client: {
10111011
webSocketURL: {
@@ -1083,7 +1083,7 @@ describe('allowed hosts', () => {
10831083
const proxyHost = devServerHost;
10841084
const proxyPort = port2;
10851085

1086-
const compiler = webpack(config);
1086+
const compiler = rspack(config);
10871087
const devServerOptions = {
10881088
client: {
10891089
webSocketURL: {
@@ -1161,7 +1161,7 @@ describe('allowed hosts', () => {
11611161
const proxyHost = devServerHost;
11621162
const proxyPort = port2;
11631163

1164-
const compiler = webpack(config);
1164+
const compiler = rspack(config);
11651165
const devServerOptions = {
11661166
client: {
11671167
webSocketURL: {
@@ -1239,7 +1239,7 @@ describe('allowed hosts', () => {
12391239
const proxyHost = devServerHost;
12401240
const proxyPort = port2;
12411241

1242-
const compiler = webpack(config);
1242+
const compiler = rspack(config);
12431243
const devServerOptions = {
12441244
client: {
12451245
webSocketURL: {
@@ -1320,7 +1320,7 @@ describe('allowed hosts', () => {
13201320
const proxyHost = devServerHost;
13211321
const proxyPort = port2;
13221322

1323-
const compiler = webpack(config);
1323+
const compiler = rspack(config);
13241324
const devServerOptions = {
13251325
client: {
13261326
webSocketURL: {
@@ -1398,7 +1398,7 @@ describe('allowed hosts', () => {
13981398
const proxyHost = devServerHost;
13991399
const proxyPort = port2;
14001400

1401-
const compiler = webpack(config);
1401+
const compiler = rspack(config);
14021402
const devServerOptions = {
14031403
client: {
14041404
webSocketURL: {
@@ -1480,7 +1480,7 @@ describe('allowed hosts', () => {
14801480
const proxyHost = devServerHost;
14811481
const proxyPort = port2;
14821482

1483-
const compiler = webpack(config);
1483+
const compiler = rspack(config);
14841484
const devServerOptions = {
14851485
client: {
14861486
webSocketURL: {
@@ -1562,7 +1562,7 @@ describe('allowed hosts', () => {
15621562
let consoleMessages;
15631563

15641564
beforeEach(() => {
1565-
compiler = webpack(config);
1565+
compiler = rspack(config);
15661566
pageErrors = [];
15671567
consoleMessages = [];
15681568
});

tests/e2e/api.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('node:path');
2-
const webpack = require('@rspack/core');
2+
const { rspack } = require('@rspack/core');
33
const { RspackDevServer: Server } = require('@rspack/dev-server');
44
const config = require('../fixtures/client-config/webpack.config');
55
const runBrowser = require('../helpers/run-browser');
@@ -50,7 +50,7 @@ describe('API', () => {
5050
RspackDevServer: WebpackDevServer,
5151
} = require('@rspack/dev-server');
5252

53-
const compiler = webpack(config);
53+
const compiler = rspack(config);
5454
server = new WebpackDevServer({ port }, compiler);
5555

5656
await server.start();
@@ -73,7 +73,7 @@ describe('API', () => {
7373

7474
describe('latest async API', () => {
7575
it('should work with async API', async () => {
76-
const compiler = webpack(config);
76+
const compiler = rspack(config);
7777
const server = new Server({ port }, compiler);
7878

7979
await server.start();
@@ -107,7 +107,7 @@ describe('API', () => {
107107
});
108108

109109
it('should work with callback API', async () => {
110-
const compiler = webpack(config);
110+
const compiler = rspack(config);
111111
const server = new Server({ port }, compiler);
112112

113113
await new Promise((resolve) => {
@@ -149,7 +149,7 @@ describe('API', () => {
149149
});
150150

151151
it('should catch errors within startCallback', async () => {
152-
const compiler = webpack(config);
152+
const compiler = rspack(config);
153153
const server = new Server(
154154
{ port, static: 'https://absolute-url.com/somewhere' },
155155
compiler,
@@ -172,14 +172,14 @@ describe('API', () => {
172172
});
173173

174174
it('should work when using configured manually', async () => {
175-
const compiler = webpack({
175+
const compiler = rspack({
176176
...config,
177177
entry: [
178178
'@rspack/core/hot/dev-server.js',
179179
`@rspack/dev-server/client/index.js?hot=true&live-reload=true"`,
180180
path.resolve(__dirname, '../fixtures/client-config/foo.js'),
181181
],
182-
plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()],
182+
plugins: [...config.plugins, new rspack.HotModuleReplacementPlugin()],
183183
});
184184
const server = new Server({ port, hot: false, client: false }, compiler);
185185

@@ -213,7 +213,7 @@ describe('API', () => {
213213
});
214214

215215
it('should work and allow to rerun dev server multiple times', async () => {
216-
const compiler = webpack(config);
216+
const compiler = rspack(config);
217217
const server = new Server({ port }, compiler);
218218

219219
await server.start();
@@ -281,7 +281,7 @@ describe('API', () => {
281281
let consoleMessages;
282282

283283
beforeEach(async () => {
284-
compiler = webpack(config);
284+
compiler = rspack(config);
285285

286286
({ page, browser } = await runBrowser());
287287

@@ -380,7 +380,7 @@ describe('API', () => {
380380
() =>
381381
new Promise((resolve) => {
382382
devServerPort = 60000 + i;
383-
const compiler = webpack(config);
383+
const compiler = rspack(config);
384384
const server = new Server(
385385
{ port: devServerPort, host: '0.0.0.0' },
386386
compiler,
@@ -634,7 +634,7 @@ describe('API', () => {
634634
'[ad42::1de2:54c2:c2fa:1234]:8080',
635635
];
636636

637-
const compiler = webpack(config);
637+
const compiler = rspack(config);
638638
const server = new Server(options, compiler);
639639

640640
for (const test of tests) {
@@ -661,7 +661,7 @@ describe('API', () => {
661661
origin: 'https://test.host',
662662
};
663663

664-
const compiler = webpack(config);
664+
const compiler = rspack(config);
665665
const server = new Server(options, compiler);
666666

667667
await server.start();

tests/e2e/app.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('node:fs');
22
const path = require('node:path');
3-
const webpack = require('@rspack/core');
3+
const { rspack } = require('@rspack/core');
44
const wdm = require('webpack-dev-middleware');
55
const { RspackDevServer: Server } = require('@rspack/dev-server');
66
const config = require('../fixtures/client-config/webpack.config');
@@ -98,7 +98,7 @@ describe('app option', () => {
9898

9999
describe(`should work using "${appName}" application and "${typeof server === 'function' ? 'custom server' : server}" server`, () => {
100100
beforeEach(async () => {
101-
compiler = webpack(config);
101+
compiler = rspack(config);
102102

103103
devServer = new Server(
104104
{

tests/e2e/built-in-routes.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const webpack = require('@rspack/core');
1+
const { rspack } = require('@rspack/core');
22
const { RspackDevServer: Server } = require('@rspack/dev-server');
33
const config = require('../fixtures/client-config/webpack.config');
44
const multiConfig = require('../fixtures/multi-public-path-config/webpack.config');
@@ -15,7 +15,7 @@ describe('Built in routes', () => {
1515
let consoleMessages;
1616

1717
beforeEach(async () => {
18-
compiler = webpack(config);
18+
compiler = rspack(config);
1919
server = new Server({ port }, compiler);
2020

2121
await server.start();
@@ -251,7 +251,7 @@ describe('Built in routes', () => {
251251
let consoleMessages;
252252

253253
beforeEach(async () => {
254-
compiler = webpack(multiConfig);
254+
compiler = rspack(multiConfig);
255255
server = new Server({ port }, compiler);
256256

257257
await server.start();

tests/e2e/client-reconnect.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const webpack = require('@rspack/core');
1+
const { rspack } = require('@rspack/core');
22
const { RspackDevServer: Server } = require('@rspack/dev-server');
33
const config = require('../fixtures/simple-config/webpack.config');
44
const runBrowser = require('../helpers/run-browser');
@@ -14,7 +14,7 @@ describe('client.reconnect option', () => {
1414
let consoleMessages;
1515

1616
beforeEach(async () => {
17-
compiler = webpack(config);
17+
compiler = rspack(config);
1818

1919
server = new Server({ port, client: { reconnect: true } }, compiler);
2020

@@ -78,7 +78,7 @@ describe('client.reconnect option', () => {
7878
let consoleMessages;
7979

8080
beforeEach(async () => {
81-
compiler = webpack(config);
81+
compiler = rspack(config);
8282

8383
server = new Server({ port, client: { reconnect: false } }, compiler);
8484

@@ -141,7 +141,7 @@ describe('client.reconnect option', () => {
141141
let consoleMessages;
142142

143143
beforeEach(async () => {
144-
compiler = webpack(config);
144+
compiler = rspack(config);
145145

146146
server = new Server({ port, client: { reconnect: 2 } }, compiler);
147147

0 commit comments

Comments
 (0)