IK
Interview Knowledge Book
Темы
Практика
Примеры
Песочница
EN
browser
Deterministic test fixture
Используйте fixed clock и fixture data, чтобы test-style assertion был repeatable.
index.js
const now = new Date('2026-06-15T00:00:00Z'); const invoice = { createdAt: '2026-06-13T00:00:00Z', total: 120 }; const ageDays = (now - new Date(invoice.createdAt)) / 86400000; const expected = { overdue: false, ageDays: 2 }; const actual = { overdue: ageDays > 30, ageDays }; console.log('invoice age days', actual.ageDays); console.log('assert', JSON.stringify(actual) === JSON.stringify(expected));
Запустить
Остановить
Сбросить