Testing: Separation of concerns
Gunar Gessner
Jun 4, 2021
Tests are usually made of three different concerns:
- Setup
- Execution
- Assertions
When writing tests, you should represent this distiction visually, using empty lines:
test("returns foo", () => { // Setup // Execution // Assertions })
Here's an example:
describe("verifyKey", () => { it("returns true for valid cryptographic keys", () => { const { publicKey } = crypto.generateKeyPair(); const actual = crypto.verifyKey(publicKey); const expected = true, assert.strictEqual(actual, expected); }); });