LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build a contract & boundary test harness
BUILD → VERIFY → EXPLAIN · STEP 4 OF 6

Test exact expiry boundaries without sleeps

Inject controlled timestamps to kill off-by-one comparison bugs.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement testInvitationExpiry(isExpiredFn) using fixed deterministic timestamps.
  2. Exercise now = expiresAt - 1 (must be valid), now = expiresAt (must be expired), and now = expiresAt + 1 (must be expired).
export function testInvitationExpiry(isExpiredFn) {
  // Test before, at, and after expiresAt deterministically.
}
Need a hint?
  • An implementation using now > expiresAt instead of now >= expiresAt must fail your test.
  • Never use setTimeout in unit boundary tests.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 4

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

If a browser fake timer passes your expiry check, why can server expiry still fail in production?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep