Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): revert all cases to CJS to fix timeout #4616

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion e2e/cases/alias/alias-by-target/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/alias/jsconfig-paths/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rspackOnlyTest(
'tsconfig paths should work and override the alias config',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
resolve: {
Expand All @@ -30,7 +30,7 @@ rspackOnlyTest(
'tsconfig paths should not work when aliasStrategy is "prefer-alias"',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
resolve: {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/alias/legacy-alias/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/alias/tsconfig-paths-references/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rspackOnlyTest(
'tsconfig paths should work with references',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
resolve: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('tsconfig paths should work and override the alias config', async ({
page,
}) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
});

Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/alias/tsconfig-paths/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('tsconfig paths should work and override the alias config', async ({
page,
}) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
resolve: {
Expand All @@ -26,7 +26,7 @@ test('tsconfig paths should not work when aliasStrategy is "prefer-alias"', asyn
page,
}) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
resolve: {
Expand Down
8 changes: 4 additions & 4 deletions e2e/cases/assets/addtional-assets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function isIncludeFile(filenames: string[], includeFilename: string) {

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

test('should allow to configure additional assets and match by path', async () => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
rsbuildConfig: {
source: {
assetsInclude: path.resolve(import.meta.dirname, 'src/assets'),
assetsInclude: path.resolve(__dirname, 'src/assets'),
},
},
});
Expand All @@ -56,7 +56,7 @@ test('should allow to configure additional assets and match by path', async () =

test('should allow to disable emit for additional assets', async () => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
rsbuildConfig: {
source: {
assetsInclude: [/\.json5$/],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { join } from 'node:path';
import { defineConfig } from '@rsbuild/core';
import fse from 'fs-extra';
import { outputFileSync } from 'fs-extra';

fse.outputFileSync(
join(import.meta.dirname, 'src/assets/test-temp-small.json5'),
outputFileSync(
join(__dirname, 'src/assets/test-temp-small.json5'),
JSON.stringify({ a: 1 }),
);
fse.outputFileSync(
join(import.meta.dirname, 'src/assets/test-temp-large.json5'),
outputFileSync(
join(__dirname, 'src/assets/test-temp-large.json5'),
JSON.stringify({ a: '1'.repeat(10000) }),
);

Expand Down
10 changes: 5 additions & 5 deletions e2e/cases/assets/asset-prefix/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

test('should allow dev.assetPrefix to be `auto`', async ({ page }) => {
const rsbuild = await dev({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
dev: {
Expand All @@ -23,7 +23,7 @@ test('should allow dev.assetPrefix to be `auto`', async ({ page }) => {

test('should allow dev.assetPrefix to be true', async ({ page }) => {
const rsbuild = await dev({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
dev: {
Expand All @@ -41,7 +41,7 @@ test('should allow dev.assetPrefix to have <port> placeholder', async ({
page,
}) => {
const rsbuild = await dev({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
dev: {
Expand All @@ -61,7 +61,7 @@ test('should allow dev.assetPrefix to have <port> placeholder', async ({

test('should allow output.assetPrefix to be `auto`', async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
output: {
Expand All @@ -79,7 +79,7 @@ test('should inject assetPrefix to env var and template correctly', async ({
page,
}) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
html: {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-inline-auto/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { pluginReact } from '@rsbuild/plugin-react';

test('should inline small assets automatically', async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [pluginReact()],
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-inline-false/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('should allow to disable assets inline with `?__inline=false`', async ({
page,
}) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [pluginReact()],
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-inline/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { pluginReact } from '@rsbuild/plugin-react';

test('should allow to inline assets with `?inline`', async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [pluginReact()],
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-retry/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function createRsbuildWithMiddleware(
assetPrefix?: string,
) {
const rsbuild = await dev({
cwd: import.meta.dirname,
cwd: __dirname,
rsbuildConfig: {
plugins: [pluginReact(), pluginAssetsRetry(options)],
dev: {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-url/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/custom-dist-path/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/assets/emit-assets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function isIncludeFile(filenames: string[], includeFilename: string) {

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

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

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/filename-function/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/filename-hash/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/filename-template-path/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

test('should allow filename.image: "[path]"', async () => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
});
const files = await rsbuild.unwrapOutputJSON();
const filenames = Object.keys(files);
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/import-json/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from '@playwright/test';

rspackOnlyTest('should import JSON correctly', async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/script-as-assets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rspackOnlyTest(
'should allow to use `new URL` to reference script as assets',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/styles-as-assets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rspackOnlyTest(
'should allow to use `new URL` to reference styles as assets',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
});

Expand Down
11 changes: 4 additions & 7 deletions e2e/cases/babel/basic/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { createRequire } from 'node:module';
import { build, rspackOnlyTest } from '@e2e/helper';
import { expect } from '@playwright/test';
import { pluginBabel } from '@rsbuild/plugin-babel';

const require = createRequire(import.meta.url);

rspackOnlyTest(
'should run babel with babel plugin correctly',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [
pluginBabel({
babelLoaderOptions: (_, { addPlugins }) => {
addPlugins([require('./plugins/myBabelPlugin.cjs')]);
addPlugins([require('./plugins/myBabelPlugin')]);
},
}),
],
Expand All @@ -30,7 +27,7 @@ rspackOnlyTest(
'should allow to exclude file from babel transformation',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
rsbuildConfig: {
source: {
Expand All @@ -40,7 +37,7 @@ rspackOnlyTest(
plugins: [
pluginBabel({
babelLoaderOptions: (_, { addPlugins }) => {
addPlugins([require('./plugins/myBabelPlugin.cjs')]);
addPlugins([require('./plugins/myBabelPlugin')]);
},
}),
],
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/babel/decorator/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rspackOnlyTest(
'should support legacy decorators and source.decorators.version in TypeScript',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [pluginBabel()],
});
Expand All @@ -22,7 +22,7 @@ rspackOnlyTest(
'should support legacy decorators and source.decorators.version in JavaScript',
async ({ page }) => {
const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
page,
plugins: [pluginBabel()],
rsbuildConfig: {
Expand Down
1 change: 0 additions & 1 deletion e2e/cases/babel/decorator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"private": true,
"name": "@e2e/babel-decorator",
"type": "module",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"private": true,
"name": "@e2e/browserslist-config-mock",
"version": "1.0.0",
"type": "module",
"main": "index.json"
}
4 changes: 2 additions & 2 deletions e2e/cases/browserslist/extends-browserslist/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { expect, test } from '@playwright/test';

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

const rsbuild = await build({
cwd: import.meta.dirname,
cwd: __dirname,
});

const files = await rsbuild.unwrapOutputJSON();
Expand Down
1 change: 0 additions & 1 deletion e2e/cases/browserslist/extends-browserslist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"private": true,
"name": "@e2e/extends-browserslist",
"version": "1.0.0",
"type": "module",
"dependencies": {
"@e2e/browserslist-config-mock": "workspace:*"
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/browserslist/package-config-array/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test';

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

const files = await rsbuild.unwrapOutputJSON();
Expand Down
Loading
Loading