agentsclimarketplace

Swift testing wait until

Skill patrickserrano/lacquer/profiles/ios/skills/swift-testing-wait-until

Use when a test needs to wait for an async state change instead of a fixed delay — the `no_task_sleep_in_tests` lint rule bans arbitrary `Task.sleep` in tests because it causes flaky failures. Provides the `waitUntil` polling helper to add to a test target instead.From its SKILL.md

Install
npx -y skills add patrickserrano/lacquer --skill swift-testing-wait-until

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.5 KB, 287 tokens by cl100k_base, as published. Nobody here has run it

waitUntil: No Task.sleep in Tests

Wait for the actual state change instead of a fixed delay. Add this TestHelpers.swift to your test target (the lint rules already exclude *TestHelpers.swift):

import Foundation

/// Thrown by `waitUntil` when the condition never became true within the timeout.
struct WaitTimeoutError: Error, CustomStringConvertible {
    let timeout: Duration
    var description: String { "waitUntil timed out after \(timeout)" }
}

/// Polls `condition` until true, throwing on timeout. Runs on the caller's actor
/// (via `#isolation`) so the closure may read `@MainActor` fixtures safely.
func waitUntil(
    timeout: Duration = .seconds(2),
    pollInterval: Duration = .milliseconds(10),
    isolation _: isolated (any Actor)? = #isolation,
    _ condition: () -> Bool
) async throws {
    let clock = ContinuousClock()
    let deadline = clock.now.advanced(by: timeout)
    while !condition() {
        guard clock.now < deadline else { throw WaitTimeoutError(timeout: timeout) }
        try await Task.sleep(for: pollInterval)
    }
}

Usage: try await waitUntil { viewModel.isLoaded } instead of try await Task.sleep(for: .seconds(1)).

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,835. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.