microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.65k stars 3.57k forks source link

[Bug]: Playwright E2E Tests Passing Locally but Failing in GitHub Actions with Next.js 14 App Router, TypeScript #32328

Closed TheodoreRed closed 1 week ago

TheodoreRed commented 2 weeks ago

Version

1.46.1

Steps to reproduce

Unfortunately, I cannot share the repository as it is private. However, I have provided a detailed explanation of the issue and the relevant code snippets on Stack Overflow, which should help in reproducing the issue:

Playwright E2E Tests Passing Locally but Failing in GitHub Actions with Next.js 14 App Router, TypeScript

Expected behavior

The end-to-end tests should pass consistently in both local environments and GitHub Actions CI.

Actual behavior

The tests pass locally but fail in GitHub Actions. The failure occurs during authentication, where the tests expect to be redirected to the home page after logging in, but instead, they are redirected back to the login page. The specific error is:

Error: Timed out 5000ms waiting for expect(locator).toHaveURL(expected)
Expected string: "***/home"
Received string: "***/login"

Additional context

Environment variables are correctly set in the GitHub Actions workflow. Dependencies are up to date. The issue is not reproducible locally; it only occurs in the GitHub Actions environment.

Environment

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M3
    Memory: 98.31 MB / 16.00 GB
  Binaries:
    Node: 20.16.0 - /usr/local/bin/node
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 9.7.1 - /usr/local/bin/pnpm
  IDEs:
    VSCode: 1.92.2 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.46.1 => 1.46.1
yury-s commented 2 weeks ago

Unfortunately, we cannot do anything about it without a reproducible example. Looking at your code, it's very likely that Azure returns a different login page/capture when you try to automate it and call from GHA workers. Try recording a trace and see what's actually happening. If you still believe this is a bug in Playwright, please extract relevant parts into a minimal project and share with us.

dgozman commented 1 week ago

Closing because we lack the information to act on this issue. If you can provide a minimal repro, please file a new issue by filling the "Bug Report" template, and link to this one.