From 440cdbfa4226be0592792f7eaf992f1744188ea1 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 28 Nov 2024 16:14:29 +0800 Subject: [PATCH] test: add e2e case for build API (#4081) --- e2e/cases/javascript-api/build/index.test.ts | 17 +++++++++++++++++ e2e/cases/javascript-api/build/src/index.js | 1 + 2 files changed, 18 insertions(+) create mode 100644 e2e/cases/javascript-api/build/index.test.ts create mode 100644 e2e/cases/javascript-api/build/src/index.js diff --git a/e2e/cases/javascript-api/build/index.test.ts b/e2e/cases/javascript-api/build/index.test.ts new file mode 100644 index 0000000000..b08638a084 --- /dev/null +++ b/e2e/cases/javascript-api/build/index.test.ts @@ -0,0 +1,17 @@ +import { expect, test } from '@playwright/test'; +import { createRsbuild } from '@rsbuild/core'; + +test('should allow to call `build` and get stats object', async () => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + }); + + const { stats, close } = await rsbuild.build(); + + await close(); + + const result = stats?.toJson({ all: true })!; + + expect(result.name).toBe('web'); + expect(result.assets?.length).toBeGreaterThan(0); +}); diff --git a/e2e/cases/javascript-api/build/src/index.js b/e2e/cases/javascript-api/build/src/index.js new file mode 100644 index 0000000000..e921523b1b --- /dev/null +++ b/e2e/cases/javascript-api/build/src/index.js @@ -0,0 +1 @@ +console.log('hello');