Skip to content

Conversation

rogerio-pereira
Copy link
Contributor

This Merge request prepare Laravel Sail image to run Pest 4 Browser tests.

I don't know how to write automated tests for docker images, but this is working on my projects


Aditional info (not required)

Besides this i had to include on package.json (but this change is related to PEST 4 package, i'll open a PR related to it on Pest 4 repo)

    "scripts": {
        ...
        "postinstall": "npx playwright install"
    },
    "devDependencies": {
        ...
        "playwright": "^1.55.0",
    },

Also i'm able to run the browser tests on my Github CI workflow

name: tests

on:
  workflow_run:
    workflows: ["linter"]
    types:
      - completed
    branches:
      - develop
      - main

jobs:
  ci:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    env: 
      PLAYWRIGHT_BROWSERS_PATH: 0   #Install playwright browsers on node_modules

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.4
          tools: composer:v2
          coverage: xdebug

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'
          cache-dependency-path: './project/package-lock.json'

      # Required for PEST 4 browser tests
      - name: Install Playwright dependencies
        run: npx playwright install-deps

      - name: Install Node Dependencies
        working-directory: ./project
        run: npm install

      - name: Install Dependencies
        working-directory: ./project
        run: composer install --no-interaction --prefer-dist --optimize-autoloader

      - name: Copy Environment File
        working-directory: ./project
        run: cp .env.example .env

      - name: Generate Application Key
        working-directory: ./project
        run: php artisan key:generate

      - name: Build Assets
        working-directory: ./project
        run: npm run build

      - name: Tests
        working-directory: ./project
        # run: php artisan test --type-coverage --mutate --parallel
        run: php artisan test --parallel

@taylorotwell taylorotwell merged commit 019a293 into laravel:1.x Aug 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants