Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Foks's avatar
Level 15

Test passes, but doesn't on GitHub via GitHub actions

Hi!

So lately I've noticed that my GitHub action test suite has begun to fail, which I initially tracked down to failing test locally. Now that my test passes locally, I expect them to pass on GitHub actions, but they don't. Any ideas on why this could happen?

0 likes
8 replies
automica's avatar

Are you able to run your tests using verbose flag or access the logs?

Foks's avatar
Level 15

From the local suite or the Github suite?

fideloper's avatar

Differences in local vs CI are almost always related to:

  1. Differences in environment variables
  2. Case insensitive file systems allowing code to run on Mac/Windows, but failing on Linux systems (which are almost always using case-sensitive file systems) due to incorrect cases used with use Foo\Bar statements.
  3. Sometimes a difference/bad assumption in database migrations/factories

Without giving us more information (what errors you're seeing, etc), we can only guess.

1 like
fideloper's avatar
Level 11

Gotcha -

What I would do is take one of those specific tests that are failing (throwing a 500 error instead of expected 200) and add $this->withoutExceptionHandling(); in the beginning of that test.

Then push that change up so GH actions runs it. You should then get some real error output that's more useful there to let you know what's going on.

Another solution may be to generate an artifact out of your laravel.log file so you have that to review when the build is fails. That's a big more complicated but not too bad:

  1. you'll need an action to run on failure and then
  2. use this action to download the laravel log file as an artifact

But the first solution there to remove exception handling (and thus get a full exception stack trace output in your failing test) might be easier.

5 likes
waldemar_enns's avatar

@fideloper That was actually really helpful. I had the same issue as the author - getting 500 errors in the pipeline for all my "expect ABC screen to be rendered" tests. Turns out, that after applying $this->withoutExceptionHandling(); I got the error message that some Vite manifest was missing at /public/build/....

I tested it locally by removing the /public/build directory (since I can always rebuild it with npm run build) and ran my tests -> GOTCHA - same errors locally.

Fix:

Simply add some npm commands into your GitHub action, e.g.:

  - name: Setup Node.js
    uses: actions/setup-node@v2
    with:
      node-version: '20.10.0'

  - name: Install npm dependencies
    run: npm ci

  - name: Build assets
    run: npm run build

Et voilá! Tests succeed :)

Please or to participate in this conversation.