diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d9c0c69..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d7d8a46..243e15a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,14 +8,22 @@ on: push: branches: - "*" + pull_request: branches: - "*" -permissions: - actions: read - contents: read - packages: read + workflow_call: + inputs: + update-snapshots: + description: "Update snapshots?" + type: boolean + + workflow_dispatch: + inputs: + update-snapshots: + description: "Update snapshots?" + type: boolean env: BROWSERCAT_API_KEY: ${{secrets.BROWSERCAT_API_KEY}} @@ -26,7 +34,7 @@ jobs: timeout-minutes: 15 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up PNPM uses: pnpm/action-setup@v2 @@ -40,18 +48,34 @@ jobs: node-version-file: .nvmrc check-latest: true - - name: Install Deps + - name: Install deps run: | pnpm install --frozen-lockfile + - name: Set up cache + id: cache + uses: actions/cache@v4 + with: + key: cache/${{github.repository}}/${{github.ref}} + restore-keys: cache/${{github.repository}}/refs/heads/master + path: .test/** + + - name: Initialize snapshots + if: ${{steps.cache.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}} + run: | + pnpm run test:bcat --update-snapshots + - name: Test + continue-on-error: true run: | pnpm run test:bcat - - name: Upload Report - uses: actions/upload-artifact@v3 + - name: Upload test report + id: report if: always() + uses: actions/upload-artifact@v4 with: name: playwright-report path: .test/spec/results/ retention-days: 30 + overwrite: true diff --git a/playwright.config.ts b/playwright.config.ts index 0641a62..79a818b 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -31,33 +31,30 @@ export default defineConfig({ maxFailures: useBC && !isCI ? 0 : 3, forbidOnly: isCI, - ignoreSnapshots: isCI, - expect: { - toMatchSnapshot: { - maxDiffPixelRatio: 0.05, - }, - }, - outputDir: '.test/spec/output', - snapshotDir: '.test/spec/snaps', - snapshotPathTemplate: '{snapshotDir}/{projectName}/{testFilePath}/{arg}{ext}', - + snapshotPathTemplate: '.test/spec/snaps/{projectName}/{testFilePath}/{arg}{ext}', testMatch: '*.spec.{ts,tsx}', - use: { - trace: 'on-first-retry', - }, + reporter: [ + ['json', {outputFile: '.test/spec/results.json'}], + ['html', {outputFolder: '.test/spec/results', open: 'never'}], + isCI ? ['github'] : ['line'], + ], reportSlowTests: { max: 5, threshold: 1000 * 15, }, - reporter: [ - ['json', {outputFile: '.test/spec/results.json'}], - ['html', {outputFolder: '.test/spec/results', open: 'never'}], - isCI ? ['github'] : ['line'], - ], + expect: { + toMatchSnapshot: { + maxDiffPixelRatio: 0.05, + }, + }, + + use: { + trace: 'on-first-retry', + }, projects: [ {