Skip to content

Commit 07723fc

Browse files
committed
test: add basic e2e case
1 parent 99044d3 commit 07723fc

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

test/basic/index.test.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { dirname } from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import { expect, test } from '@playwright/test';
44
import { createRsbuild } from '@rsbuild/core';
5-
import { pluginBasicSsl } from '../../src';
5+
import { pluginBasicSsl } from '../../dist';
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

9-
test('should render page as expected', async ({ page }) => {
9+
test('should print HTTPS server URLs', async () => {
1010
const rsbuild = await createRsbuild({
1111
cwd: __dirname,
1212
rsbuildConfig: {
@@ -16,25 +16,11 @@ test('should render page as expected', async ({ page }) => {
1616

1717
const { server, urls } = await rsbuild.startDevServer();
1818

19-
await page.goto(urls[0]);
20-
expect(await page.evaluate('window.test')).toBe(1);
21-
22-
await server.close();
23-
});
24-
25-
test('should build succeed', async ({ page }) => {
26-
const rsbuild = await createRsbuild({
27-
cwd: __dirname,
28-
rsbuildConfig: {
29-
plugins: [pluginBasicSsl()],
30-
},
19+
await new Promise((resolve) => {
20+
rsbuild.onDevCompileDone(resolve);
3121
});
3222

33-
await rsbuild.build();
34-
const { server, urls } = await rsbuild.preview();
35-
36-
await page.goto(urls[0]);
37-
expect(await page.evaluate('window.test')).toBe(1);
23+
expect(urls.every((url) => url.startsWith('https'))).toBeTruthy();
3824

3925
await server.close();
4026
});

test/basic/rsbuild.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { pluginBasicSsl } from '@rsbuild/plugin-basic-ssl';
2+
3+
export default {
4+
plugins: [pluginBasicSsl()],
5+
};

test/basic/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
window.test = 1;
1+
console.log('1');

0 commit comments

Comments
 (0)