DEV Community

Brian Hogg
Brian Hogg

Posted on

Playwright Github Actions question

Hey all! I'm trying to integrate Playwright into my CI pipeline with a NextJS app, Github and Vercel as the host. I've got Playwright (the first time I'm using it) loaded and running a couple sample tests, and it comes with a boilerplate workflow playwright.yml file like this:

name: Playwright Tests
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "14.x"
      - name: Install dependencies
        run: npm ci
      - name: Install Playwright
        run: npx playwright install --with-deps
      - name: Run Jest
        run: npm run test
      - name: Run Playwright tests
        run: npx playwright test
      - uses: actions/upload-artifact@v2
        if: always()
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 30

Enter fullscreen mode Exit fullscreen mode

This works fine locally since I have my dev server running, but how can I test this as part of the Github Action? I assume I'm missing something very simple that will run the server to let me actually test it, but can anyone point me in the right direction?

Thanks!

Update:
I hadn't realized you needed to separately enable the webServer block in the playwright.config.ts file. In my case, using Next, I had to set it to:

webServer: {
  command: "npm run build && npm run start",
  port: 3000,
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)