Checkout is tracked, with two views
An expectation turns a spy into a strict mock: verify() fails the test for an event that never came or one nobody expected.
Run it
swift test --filter checkoutTracksItsEvents
CheckThatAMockWasUsedGuide.swift
@Test("Completing a checkout tracks it and two views") func checkoutTracksItsEvents() { analytics.trackSpy.expect("checkout") analytics.trackSpy.expect(times: 2) { event in event.hasPrefix("view") } checkout.complete() analytics.trackSpy.verify() }