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?
Differences in local vs CI are almost always related to:
Differences in environment variables
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.
Sometimes a difference/bad assumption in database migrations/factories
Without giving us more information (what errors you're seeing, etc), we can only guess.
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:
@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.: