From 6449e2fdb807df09042c4e5dae667540868aa6bc Mon Sep 17 00:00:00 2001 From: Rain <958414905@qq.com> Date: Wed, 1 Nov 2023 12:00:28 +0800 Subject: [PATCH] chore(e2e): optimize variable and timeout --- .github/workflows/nocobase-test-e2e.yml | 6 +++++- packages/core/build/src/buildClient.ts | 2 +- packages/core/build/src/buildPlugin.ts | 2 +- playwright.config.ts | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nocobase-test-e2e.yml b/.github/workflows/nocobase-test-e2e.yml index c2e007047..7118b486a 100644 --- a/.github/workflows/nocobase-test-e2e.yml +++ b/.github/workflows/nocobase-test-e2e.yml @@ -56,11 +56,15 @@ jobs: ${{ runner.os }}-yarn- - run: yarn install - - run: yarn build + - name: yarn build + run: yarn build + env: + __E2E__: true - run: npx playwright install --with-deps - name: Test with postgres run: yarn test:e2e env: + __E2E__: true LOGGER_LEVEL: error DB_DIALECT: postgres DB_HOST: postgres diff --git a/packages/core/build/src/buildClient.ts b/packages/core/build/src/buildClient.ts index f48cee1b8..5f16c6d83 100644 --- a/packages/core/build/src/buildClient.ts +++ b/packages/core/build/src/buildClient.ts @@ -36,7 +36,7 @@ export function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: boolean define: { 'process.env.NODE_ENV': JSON.stringify('production'), 'process.env.__TEST__': false, - 'process.env.__E2E__': false, + 'process.env.__E2E__': process.env.__E2E__ ? true : false, }, build: { minify: false, diff --git a/packages/core/build/src/buildPlugin.ts b/packages/core/build/src/buildPlugin.ts index e67cb9225..89a3d69e6 100644 --- a/packages/core/build/src/buildPlugin.ts +++ b/packages/core/build/src/buildPlugin.ts @@ -304,7 +304,7 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou define: { 'process.env.NODE_ENV': JSON.stringify('production'), 'process.env.__TEST__': false, - 'process.env.__E2E__': false, + 'process.env.__E2E__': process.env.__E2E__ ? true : false, }, logLevel: 'warn', build: { diff --git a/playwright.config.ts b/playwright.config.ts index fb3968c2a..7a882c6d2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,7 +1,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ - timeout: process.env.CI ? 5 * 60 * 1000 : 60 * 1000, + timeout: process.env.CI ? 60 * 1000 : 30 * 1000, // Look for test files in the "tests" directory, relative to this configuration file. testDir: 'packages',