TIL is my collection of short, technical daily learnings. 235 and counting.
Focus a JS Test
A vital testing skill is focusing a test. When iterating on a failing test, we want that test under microscope. The way I do this in JavaScript is .only: import {describe, expect, test} from 'vitest'; import {sum} from './sum.js'; test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); }); describe.only('adding fours', () => { test('adds 4 + 4 to equal 8', () => { expect(sum(4, 4)).toBe(8); }); }); ...