Skip to content

Commit

Permalink
test(e2e): polish source related cases (#4311)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jan 1, 2025
1 parent ba8a1d9 commit 0719125
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 93 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"name": "@e2e/webpack-source-map",
"version": "1.0.0",
"dependencies": {
"source-map": "0.7.4",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"source-map": "0.7.4"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion e2e/cases/source/basic/src/common/test.js

This file was deleted.

9 changes: 0 additions & 9 deletions e2e/cases/source/basic/src/index.js

This file was deleted.

34 changes: 34 additions & 0 deletions e2e/cases/source/define/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { build, dev, gotoPage } from '@e2e/helper';
import { expect, test } from '@playwright/test';

test('should allow to define global variables in development', async ({
page,
}) => {
const rsbuild = await dev({
cwd: __dirname,
page,
});

await gotoPage(page, rsbuild);

const testEl = page.locator('#test-el');
await expect(testEl).toHaveText('aaaaa');

await rsbuild.close();
});

test('should allow to define global variables in production build', async ({
page,
}) => {
const rsbuild = await build({
cwd: __dirname,
page,
});

await gotoPage(page, rsbuild);

const testEl = page.locator('#test-el');
await expect(testEl).toHaveText('aaaaa');

await rsbuild.close();
});
9 changes: 9 additions & 0 deletions e2e/cases/source/define/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
source: {
define: {
ENABLE_TEST: JSON.stringify(true),
},
},
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions e2e/cases/source/pre-entry/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { build, dev } from '@e2e/helper';
import { expect, test } from '@playwright/test';

test('should allow to configure pre-entry in development', async ({ page }) => {
const rsbuild = await dev({
cwd: __dirname,
page,
});

await expect(page.innerHTML('#test-el')).resolves.toBe('aaaaa');
await expect(page.evaluate('window.aa')).resolves.toBe(2);

await rsbuild.close();
});

test('should allow to configure pre-entry in production build', async ({
page,
}) => {
const rsbuild = await build({
cwd: __dirname,
page,
});

await expect(page.innerHTML('#test-el')).resolves.toBe('aaaaa');
await expect(page.evaluate('window.aa')).resolves.toBe(2);

await rsbuild.close();
});
7 changes: 7 additions & 0 deletions e2e/cases/source/pre-entry/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
source: {
preEntry: ['./src/pre.js'],
},
});
1 change: 1 addition & 0 deletions e2e/cases/source/pre-entry/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.aa = 2;
File renamed without changes.
67 changes: 0 additions & 67 deletions e2e/cases/source/source.test.ts

This file was deleted.

20 changes: 7 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 0719125

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ❌ failure
rspress ✅ success
rslib ❌ failure
examples ✅ success

Please sign in to comment.