Tests before code makes sense when fixing bugs. Red-green specifically.
1: get bug
2: write tests that should work, but don’t because of bug
3: fix bug
4: confirm fix by running tests
Makes things a LOT easier for people checking the PR, they can just confirm the tests are correct pretty much.
As a bonus the same bug can’t surface again.