From ddbda102d3377ac890e775a7f3355c4ff21189ed Mon Sep 17 00:00:00 2001 From: Mohammad Bagher Abiat Date: Sat, 8 Apr 2023 15:23:35 +0330 Subject: [PATCH] test: each test case for browser (#3100) --- .github/workflows/ci.yml | 37 +++++++++++++++++++ package.json | 4 +- .../vitest/src/integrations/browser/server.ts | 1 + test/browser/test/basic.test.ts | 7 ++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 707d6c2ff727..b8741ad129c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,6 +140,43 @@ jobs: env: BROWSER: ${{ matrix.browser[1] }} + test-browser-windows: + runs-on: windows-latest + strategy: + matrix: + browser: [[chrome, chromium], [edge, webkit]] + + timeout-minutes: 10 + + env: + BROWSER: ${{ matrix.browser[0] }} + steps: + - uses: actions/checkout@v3 + + - uses: ./.github/actions/setup-and-cache + with: + node-version: 18 + + - uses: browser-actions/setup-chrome@v1 + - uses: browser-actions/setup-edge@v1 + + - name: Install + run: pnpm i + + - name: Install Playwright Dependencies + run: pnpx playwright install-deps + + - name: Build + run: pnpm run build + + - name: Test Browser (webdriverio) + run: pnpm run test:browser:webdriverio + + - name: Test Browser (playwright) + run: pnpm run test:browser:playwright + env: + BROWSER: ${{ matrix.browser[1] }} + test-browser-safari: runs-on: macos-latest timeout-minutes: 10 diff --git a/package.json b/package.json index c0d17ecfdb54..13c267057421 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "ui:build": "vite build packages/ui", "ui:dev": "vite packages/ui", "ui:test": "npm -C packages/ui run test:run", - "test:browser:webdriverio": "npm -C test/browser run test:webdriverio", - "test:browser:playwright": "npm -C test/browser run test:playwright" + "test:browser:webdriverio": "pnpm -C test/browser run test:webdriverio", + "test:browser:playwright": "pnpm -C test/browser run test:playwright" }, "devDependencies": { "@antfu/eslint-config": "^0.38.4", diff --git a/packages/vitest/src/integrations/browser/server.ts b/packages/vitest/src/integrations/browser/server.ts index 61ef7bad1967..67ebd48f772f 100644 --- a/packages/vitest/src/integrations/browser/server.ts +++ b/packages/vitest/src/integrations/browser/server.ts @@ -42,6 +42,7 @@ export async function createBrowserServer(ctx: Vitest, options: UserConfig) { } config.server = server + config.server.fs = { strict: false } config.optimizeDeps ??= {} config.optimizeDeps.entries ??= [] diff --git a/test/browser/test/basic.test.ts b/test/browser/test/basic.test.ts index 6f7a12cdec04..39071edc652b 100644 --- a/test/browser/test/basic.test.ts +++ b/test/browser/test/basic.test.ts @@ -7,3 +7,10 @@ it('basic', async () => { it('basic 2', () => { expect(globalThis.window).toBeDefined() }) + +it.each([ + ['x', true], + ['y', false], +])('%s is x', (val, expectedResult) => { + expect(val === 'x').toBe(expectedResult) +})