Skip to content

Commit

Permalink
Merge pull request #35 from keller-mark/keller-mark/playwright
Browse files Browse the repository at this point in the history
Use playwright to count renders/inits
  • Loading branch information
keller-mark authored Jan 15, 2024
2 parents f2be5e4 + fac897c commit 597a92e
Show file tree
Hide file tree
Showing 10 changed files with 416 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-islands-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"demo": patch
---

Playwright e2e test for counting re-renders.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
version: 8
run_install: true
- run: pnpm run build
run: pnpm exec playwright test
- run: pnpm run changeset-status
- name: Create Release Pull Request or Publish to NPM
if: github.repository == 'keller-mark/use-coordination'
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Adapted from https://github.com/actions/starter-workflows/blob/e9e00b017736d3b3811cedf1ee2e8ceb3c48e3dd/ci/npm-publish.yml
name: Test
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
pre_deploy:
runs-on: ubuntu-latest
name: Deploy
permissions:
# Permissions required for the changesets action
# to be able to create a new branch and open a pull request
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
# Reference: https://github.com/changesets/changesets/issues/517#issuecomment-1182094769
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: true
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- run: pnpm run build
- name: Run Playwright tests
run: pnpm exec playwright test
- run: pnpm run changeset-status
#- uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ examples/**/CHANGELOG.md
RELEASE_NOTES.md
*.tsbuildinfo
stats.html
packages/*/coverage/
packages/*/coverage/
test-results/
playwright-report/
blob-report/
playwright/.cache/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"mdast-util-to-string": "^1.0.6",
"remark-parse": "^7.0.1",
"remark-stringify": "^7.0.3",
"unified": "^8.3.2"
"unified": "^8.3.2",
"@playwright/test": "^1.40.1"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
79 changes: 79 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './sites/demo/tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm run start-demo',
url: 'http://localhost:3000/use-coordination/',
// reuseExistingServer: !process.env.CI,
},
});

63 changes: 48 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion sites/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"@tanstack/react-query": "^4.35.3",
"d3-dsv": "^3.0.1",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react-dom": "^18.0.0",
"@use-coordination/all": "workspace:*",
"zod": "^3.21.4"
},
"devDependencies": {
"@vitejs/plugin-react": "^1.3.2",
Expand Down
Loading

0 comments on commit 597a92e

Please sign in to comment.