Skip to content

Commit 5030253

Browse files
authored
test(e2e): revert all cases to CJS to fix timeout (#4616)
1 parent d8e579e commit 5030253

File tree

351 files changed

+774
-902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+774
-902
lines changed

e2e/cases/alias/alias-by-target/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow to set alias by build target', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/alias/jsconfig-paths/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rspackOnlyTest(
55
'tsconfig paths should work and override the alias config',
66
async ({ page }) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
rsbuildConfig: {
1111
resolve: {
@@ -30,7 +30,7 @@ rspackOnlyTest(
3030
'tsconfig paths should not work when aliasStrategy is "prefer-alias"',
3131
async ({ page }) => {
3232
const rsbuild = await build({
33-
cwd: import.meta.dirname,
33+
cwd: __dirname,
3434
page,
3535
rsbuildConfig: {
3636
resolve: {

e2e/cases/alias/legacy-alias/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow to use the legacy `source.alias` config', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/alias/tsconfig-paths-references/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rspackOnlyTest(
55
'tsconfig paths should work with references',
66
async ({ page }) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
rsbuildConfig: {
1111
resolve: {

e2e/cases/alias/tsconfig-paths-specify-config/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test('tsconfig paths should work and override the alias config', async ({
55
page,
66
}) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
});
1111

e2e/cases/alias/tsconfig-paths/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test('tsconfig paths should work and override the alias config', async ({
55
page,
66
}) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
rsbuildConfig: {
1111
resolve: {
@@ -26,7 +26,7 @@ test('tsconfig paths should not work when aliasStrategy is "prefer-alias"', asyn
2626
page,
2727
}) => {
2828
const rsbuild = await build({
29-
cwd: import.meta.dirname,
29+
cwd: __dirname,
3030
page,
3131
rsbuildConfig: {
3232
resolve: {

e2e/cases/assets/addtional-assets/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function isIncludeFile(filenames: string[], includeFilename: string) {
88

99
test('should allow to configure additional assets and match by RegExp', async () => {
1010
const rsbuild = await build({
11-
cwd: import.meta.dirname,
11+
cwd: __dirname,
1212
rsbuildConfig: {
1313
source: {
1414
assetsInclude: [/\.json5$/],
@@ -32,10 +32,10 @@ test('should allow to configure additional assets and match by RegExp', async ()
3232

3333
test('should allow to configure additional assets and match by path', async () => {
3434
const rsbuild = await build({
35-
cwd: import.meta.dirname,
35+
cwd: __dirname,
3636
rsbuildConfig: {
3737
source: {
38-
assetsInclude: path.resolve(import.meta.dirname, 'src/assets'),
38+
assetsInclude: path.resolve(__dirname, 'src/assets'),
3939
},
4040
},
4141
});
@@ -56,7 +56,7 @@ test('should allow to configure additional assets and match by path', async () =
5656

5757
test('should allow to disable emit for additional assets', async () => {
5858
const rsbuild = await build({
59-
cwd: import.meta.dirname,
59+
cwd: __dirname,
6060
rsbuildConfig: {
6161
source: {
6262
assetsInclude: [/\.json5$/],

e2e/cases/assets/addtional-assets/rsbuild.config.mjs e2e/cases/assets/addtional-assets/rsbuild.config.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { join } from 'node:path';
22
import { defineConfig } from '@rsbuild/core';
3-
import fse from 'fs-extra';
3+
import { outputFileSync } from 'fs-extra';
44

5-
fse.outputFileSync(
6-
join(import.meta.dirname, 'src/assets/test-temp-small.json5'),
5+
outputFileSync(
6+
join(__dirname, 'src/assets/test-temp-small.json5'),
77
JSON.stringify({ a: 1 }),
88
);
9-
fse.outputFileSync(
10-
join(import.meta.dirname, 'src/assets/test-temp-large.json5'),
9+
outputFileSync(
10+
join(__dirname, 'src/assets/test-temp-large.json5'),
1111
JSON.stringify({ a: '1'.repeat(10000) }),
1212
);
1313

e2e/cases/assets/asset-prefix/index.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow dev.assetPrefix to be `auto`', async ({ page }) => {
55
const rsbuild = await dev({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
page,
88
rsbuildConfig: {
99
dev: {
@@ -23,7 +23,7 @@ test('should allow dev.assetPrefix to be `auto`', async ({ page }) => {
2323

2424
test('should allow dev.assetPrefix to be true', async ({ page }) => {
2525
const rsbuild = await dev({
26-
cwd: import.meta.dirname,
26+
cwd: __dirname,
2727
page,
2828
rsbuildConfig: {
2929
dev: {
@@ -41,7 +41,7 @@ test('should allow dev.assetPrefix to have <port> placeholder', async ({
4141
page,
4242
}) => {
4343
const rsbuild = await dev({
44-
cwd: import.meta.dirname,
44+
cwd: __dirname,
4545
page,
4646
rsbuildConfig: {
4747
dev: {
@@ -61,7 +61,7 @@ test('should allow dev.assetPrefix to have <port> placeholder', async ({
6161

6262
test('should allow output.assetPrefix to be `auto`', async ({ page }) => {
6363
const rsbuild = await build({
64-
cwd: import.meta.dirname,
64+
cwd: __dirname,
6565
page,
6666
rsbuildConfig: {
6767
output: {
@@ -79,7 +79,7 @@ test('should inject assetPrefix to env var and template correctly', async ({
7979
page,
8080
}) => {
8181
const rsbuild = await build({
82-
cwd: import.meta.dirname,
82+
cwd: __dirname,
8383
page,
8484
rsbuildConfig: {
8585
html: {

e2e/cases/assets/assets-inline-auto/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { pluginReact } from '@rsbuild/plugin-react';
44

55
test('should inline small assets automatically', async ({ page }) => {
66
const rsbuild = await build({
7-
cwd: import.meta.dirname,
7+
cwd: __dirname,
88
page,
99
plugins: [pluginReact()],
1010
});

e2e/cases/assets/assets-inline-false/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test('should allow to disable assets inline with `?__inline=false`', async ({
66
page,
77
}) => {
88
const rsbuild = await build({
9-
cwd: import.meta.dirname,
9+
cwd: __dirname,
1010
page,
1111
plugins: [pluginReact()],
1212
});

e2e/cases/assets/assets-inline/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { pluginReact } from '@rsbuild/plugin-react';
44

55
test('should allow to inline assets with `?inline`', async ({ page }) => {
66
const rsbuild = await build({
7-
cwd: import.meta.dirname,
7+
cwd: __dirname,
88
page,
99
plugins: [pluginReact()],
1010
});

e2e/cases/assets/assets-retry/helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function createRsbuildWithMiddleware(
8080
assetPrefix?: string,
8181
) {
8282
const rsbuild = await dev({
83-
cwd: import.meta.dirname,
83+
cwd: __dirname,
8484
rsbuildConfig: {
8585
plugins: [pluginReact(), pluginAssetsRetry(options)],
8686
dev: {

e2e/cases/assets/assets-url/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow to get assets URL with `?url`', async ({ page }) => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
page,
88
});
99

e2e/cases/assets/custom-dist-path/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow to custom dist path of different files', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/assets/emit-assets/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function isIncludeFile(filenames: string[], includeFilename: string) {
77

88
test('should allow to disable emit assets for node target', async () => {
99
const rsbuild = await build({
10-
cwd: import.meta.dirname,
10+
cwd: __dirname,
1111
});
1212

1313
const files = await rsbuild.unwrapOutputJSON();
@@ -22,7 +22,7 @@ test('should allow to disable emit assets for node target', async () => {
2222

2323
test('should allow to disable emit assets for json assets', async () => {
2424
const rsbuild = await build({
25-
cwd: import.meta.dirname,
25+
cwd: __dirname,
2626
});
2727

2828
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/assets/filename-function/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow to custom filename by function', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/assets/filename-hash/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from '@playwright/test';
33

44
rspackOnlyTest('should allow to set hash format to fullhash', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/assets/filename-template-path/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should allow filename.image: "[path]"', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88
const files = await rsbuild.unwrapOutputJSON();
99
const filenames = Object.keys(files);

e2e/cases/assets/import-json/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from '@playwright/test';
33

44
rspackOnlyTest('should import JSON correctly', async ({ page }) => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
page,
88
});
99

e2e/cases/assets/script-as-assets/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rspackOnlyTest(
55
'should allow to use `new URL` to reference script as assets',
66
async ({ page }) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
});
1111

e2e/cases/assets/styles-as-assets/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rspackOnlyTest(
55
'should allow to use `new URL` to reference styles as assets',
66
async ({ page }) => {
77
const rsbuild = await build({
8-
cwd: import.meta.dirname,
8+
cwd: __dirname,
99
page,
1010
});
1111

e2e/cases/babel/basic/index.test.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
import { createRequire } from 'node:module';
21
import { build, rspackOnlyTest } from '@e2e/helper';
32
import { expect } from '@playwright/test';
43
import { pluginBabel } from '@rsbuild/plugin-babel';
54

6-
const require = createRequire(import.meta.url);
7-
85
rspackOnlyTest(
96
'should run babel with babel plugin correctly',
107
async ({ page }) => {
118
const rsbuild = await build({
12-
cwd: import.meta.dirname,
9+
cwd: __dirname,
1310
page,
1411
plugins: [
1512
pluginBabel({
1613
babelLoaderOptions: (_, { addPlugins }) => {
17-
addPlugins([require('./plugins/myBabelPlugin.cjs')]);
14+
addPlugins([require('./plugins/myBabelPlugin')]);
1815
},
1916
}),
2017
],
@@ -30,7 +27,7 @@ rspackOnlyTest(
3027
'should allow to exclude file from babel transformation',
3128
async ({ page }) => {
3229
const rsbuild = await build({
33-
cwd: import.meta.dirname,
30+
cwd: __dirname,
3431
page,
3532
rsbuildConfig: {
3633
source: {
@@ -40,7 +37,7 @@ rspackOnlyTest(
4037
plugins: [
4138
pluginBabel({
4239
babelLoaderOptions: (_, { addPlugins }) => {
43-
addPlugins([require('./plugins/myBabelPlugin.cjs')]);
40+
addPlugins([require('./plugins/myBabelPlugin')]);
4441
},
4542
}),
4643
],

e2e/cases/babel/decorator/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rspackOnlyTest(
66
'should support legacy decorators and source.decorators.version in TypeScript',
77
async ({ page }) => {
88
const rsbuild = await build({
9-
cwd: import.meta.dirname,
9+
cwd: __dirname,
1010
page,
1111
plugins: [pluginBabel()],
1212
});
@@ -22,7 +22,7 @@ rspackOnlyTest(
2222
'should support legacy decorators and source.decorators.version in JavaScript',
2323
async ({ page }) => {
2424
const rsbuild = await build({
25-
cwd: import.meta.dirname,
25+
cwd: __dirname,
2626
page,
2727
plugins: [pluginBabel()],
2828
rsbuildConfig: {
-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"private": true,
33
"name": "@e2e/babel-decorator",
4-
"type": "module",
54
"version": "1.0.0"
65
}

e2e/cases/browserslist/browserslist-config-mock/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"private": true,
33
"name": "@e2e/browserslist-config-mock",
44
"version": "1.0.0",
5-
"type": "module",
65
"main": "index.json"
76
}

e2e/cases/browserslist/extends-browserslist/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { expect, test } from '@playwright/test';
33

44
test('extends browserslist and downgrade the syntax', async () => {
55
const originalCwd = process.cwd();
6-
process.chdir(import.meta.dirname);
6+
process.chdir(__dirname);
77

88
const rsbuild = await build({
9-
cwd: import.meta.dirname,
9+
cwd: __dirname,
1010
});
1111

1212
const files = await rsbuild.unwrapOutputJSON();

e2e/cases/browserslist/extends-browserslist/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"private": true,
33
"name": "@e2e/extends-browserslist",
44
"version": "1.0.0",
5-
"type": "module",
65
"dependencies": {
76
"@e2e/browserslist-config-mock": "workspace:*"
87
},

e2e/cases/browserslist/package-config-array/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';
33

44
test('should read browserslist array from package.json', async () => {
55
const rsbuild = await build({
6-
cwd: import.meta.dirname,
6+
cwd: __dirname,
77
});
88

99
const files = await rsbuild.unwrapOutputJSON();

0 commit comments

Comments
 (0)