Andy Swick

they/them

Reading comfort
Text size A A A
Reduce motion
Appearance Light Dark Auto
Tip

Keep Factories Simple

Andy Swick

1 min read

If you need to remove things after creating a model using a factory, it's doing too much. Convert it to a helper method instead. Having afterCreating in a configure method that creates other models, usually is a smell and slows down tests considerably. Bare factories should be the most barebones version of a model.

Get Enby·Mail

Monthly-ish updates: notes on Laravel, prints in progress, the occasional missing 1×2 plate.

First name
Email

I only email you about what you signed up for. Unsubscribe any time.

More from the Log

The whole log
Reading comfort
Text size A A A
Reduce motion
Appearance Light Dark Auto