> ## Content Index
> Fetch the complete content index at: https://logbuch-dev-blog.nichedthemes.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Why I write the test first, sometimes
- URL: https://logbuch-dev-blog.nichedthemes.com/why-i-write-the-test-first-sometimes/
- Published: 2023-03-14T18:00:00.000Z
- Updated: 2023-03-14T18:00:00.000Z
- Description: Test first when I know what the answer should be. Code first when I am still finding out what the question is.
- Author: Mira Okafor
- Tags: Backend, TypeScript, #small-caps, #Import 2026-11-19 07:37

I write the test first when I know what the answer should be: a parser, a price calculation, a bug someone reported with an example. I write the code first when I am still finding out what the question is, and add the test once I know.

That rule has held for three years. It fails in one place: code I am sure I understand. Those are the functions that come back with a bug report a month later.

```ts
test('a key without = has an empty value', () => {
  assert.equal(parse('a&b=1').get('a'), '');
});
```