Performance: Writing test cases
MEDIUM IMPACT
Writing test cases affects development speed and feedback loop but can indirectly impact build and test execution time.
test('adds numbers', () => { expect(add(1, 2)).toBe(3); });
test('adds numbers', () => { expect(add(1, 2)).toBe(3); expect(add(1, 2)).toBe(3); expect(add(1, 2)).toBe(3); });
| Pattern | CPU Usage | Test Runtime | Parallelism | Verdict |
|---|---|---|---|---|
| Redundant assertions | High | Long | No | [X] Bad |
| Single assertion per test | Low | Short | No | [OK] Good |
| Sequential tests | Moderate | Long | No | [X] Bad |
| Parallel tests | High (efficient) | Short | Yes | [OK] Good |
| Heavy setup/teardown per test | High | Long | No | [X] Bad |
| Heavy setup/teardown once per suite | Moderate | Shorter | No | [OK] Good |