Skip to main content

Command Palette

Search for a command to run...

When tests randomly fail in Laravel...

Updated
1 min read
L

I've discovered coding back in 2013 and three years later I spent all my summer building my first Laravel app which is still in production by the non-profit I've built for.

Now I'm struggling to find the balance between enjoying the power of "I can build this myself" and not chocking myself to death trying to build everything myself.

As it is common for developers to be less articulate, I decided to leverage writing about my endeavours, to keep me up.

One thing I learned today, or actually was reminded of, that when tests begin to fail randomly on reruns, it is often that the factory of the model used may have been configured to use ->randomElement([...]) and therefore on certain combination that wouldn't occur on production flow is causing the tests to fail.

I first encountered this a couple of years ago and was pulling my hair trying to understand why this seemingly abnormal behaviour was happening. From wiping out database, to setting up a dedicated test instance, until I git bisect that it was when I updated my factory class.

Hopefully writing this will help me remember this sooner in the consecutive times which I'm afraid gonna happen.

What have I learned today...

Part 3 of 3

These are my "sticky" notes on lessons that I discovered at the cost of great inconvenience or pain as a self-taught web artisan.

Start from the beginning

Working with legacy hurts...

A small rant about legacy systems + what do I learn from this