Skip to content

Commit

Permalink
Merge pull request #58 from slidr-app/transition-tests-to-playwright
Browse files Browse the repository at this point in the history
Transition tests to playwright
  • Loading branch information
codyzu authored Feb 12, 2024
2 parents 0908fe6 + 8c135c8 commit eb38f7a
Show file tree
Hide file tree
Showing 27 changed files with 638 additions and 844 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ public/pwa-*.png
/test-results/
/playwright-report/
/playwright/.cache/
.pnpm-store
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ pnpm run emulators
pnpm run test:start [args for vitest]
```

#### E2E Tests

```
pnpm run test:e2e
```

Snapshots are platform dependent. To update the snapshots with docker (required when developing with mac):

```sh
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.39.0-jammy /bin/bash
# host is now at 192.168.5.2 or host.docker.internal
npm install -g pnpm
# remove @vite-pwa/assets-generator from package.json
# or apt install default-jre libvips libvips-dev build-essential
pnpm install
pnpm run test:e2e:snapshots
```

### Build

Create a production build:
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
"build:all": "pwa-assets-generator && pnpm run build && pnpm run build:functions",
"deploy": "firebase deploy --only functions:renderForBot,auth,firestore,storage,hosting",
"generate-pwa-assets": "pwa-assets-generator",
"test": "pnpm run emulators:exec 'pnpm run test:start'",
"test:all": "pnpm run emulators:exec 'pnpm run test:start --run && pnpm run test:e2e:start'",
"test:once": "pnpm run emulators:exec 'pnpm run test:start --run'",
"test:ui": "pnpm run emulators:exec 'pnpm run test:start --ui'",
"test:start": "FIRESTORE_EMULATOR_HOST=\"127.0.0.1:8081\" vitest --mode emulator",
"coverage": "pnpm run emulators:exec 'pnpm run test:start --run --coverage'",
"test": "vitest",
"test:all": "pnpm run test:once && pnpm run test:e2e",
"test:once": "pnpm run test --run",
"test:ui": "pnpm run test --ui",
"coverage": "pnpm run test:once --coverage",
"emulators": "firebase emulators:start --project demo-test --only auth,firestore,storage",
"emulators:exec": "firebase emulators:exec --project demo-test --only auth,firestore,storage",
"coverage:report": "nyc report --temp-dir ./coverage/tmp --reporter=text --reporter=lcov --reporter=text-summary --exclude-after-remap false",
"test:e2e": "pnpm run emulators:exec --import test-data 'pnpm run test:e2e:start'",
"test:e2e:coverage": "rm -Rf ./coverage && COVERAGE=1 pnpm run emulators:exec --import test-data 'pnpm run test:e2e:start' && pnpm run coverage:report",
"test:e2e:ui": "pnpm run emulators:exec --import test-data 'pnpm run test:e2e:start --ui'",
"test:e2e:snapshots": "pnpm run emulators:exec --import test-data 'pnpm run test:e2e:start --update-snapshots'",
"test:e2e:start": "FIRESTORE_EMULATOR_HOST=\"127.0.0.1:8081\" playwright test"
},
"dependencies": {
Expand Down Expand Up @@ -95,4 +95,4 @@
"xo": "^0.54.2"
},
"packageManager": "pnpm@8.15.1+sha256.245fe901f8e7fa8782d7f17d32b6a83995e2ae03984cb5b62b8949bfdc27c7b5"
}
}
7 changes: 6 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ export default defineConfig({
{
name: 'chromium',
// Use: {...devices['Desktop Chrome'], storageState: STORAGE_STATE},
use: {...devices['Desktop Chrome']},
use: {
...devices['Desktop Chrome'],
// https://playwrightsolutions.com/how-do-i-access-the-browser-clipboard-with-playwright/
// https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions
permissions: ['clipboard-read', 'clipboard-write'],
},
},
// {
// name: 'chromium - no sign-in',
Expand Down
135 changes: 0 additions & 135 deletions src/pages/Audience.Test.tsx

This file was deleted.

163 changes: 0 additions & 163 deletions src/pages/Home.Test.tsx

This file was deleted.

Loading

0 comments on commit eb38f7a

Please sign in to comment.