Docs menu

Test API

Matchers

Every matcher the Vitest plugin adds to expect, with its name in Python (pytest-channelstack) and in the Rust SDK. Why matchers wait the way they do is in Waiting and quiet.

await expect(msg.thread).toHaveReplyFrom("my-agent", { text: /incident/i });await expect(msg.thread).toHaveRepliesFrom(slack.app, { count: 1 });await expect(channel).not.toHaveChannelMessageFrom("my-agent");

How they wait#

Every matcher is async: await it.

KindWaitsThen
PositivePolls (every 50ms) until the condition holdsPasses as soon as it holds; fails at timeout
Negative (.not)Until the app has been quiet for quietFor, watching for the whole windowChecks once
Exact count (count, times)Until the app has been quiet for quietFor, watching for the whole windowChecks once

"Quiet" means no API call in flight, no delivery in flight or about to be retried, and no open stream, in the subject's session. A quiet wait that runs out of time fails with Timed out after <n>ms waiting for the agent to be quiet for <n>ms, plus what is still open.

Live, channelstack can't see when the app is done: proxy mode will, once it reads the app's calls back live (#24). Until then, once a session has acted live, its quiet check is refused with action_requires, so negative and exact-count matchers skip the test there.

OptionTypeDefaultOn
timeoutDurationThe plugin's timeout (10s)Every matcher but toBeEphemeralFor
quietForDurationThe plugin's quietFor (750ms)Every matcher under .not, and exact-count ones

A failure message says what was expected, then what is there. When the check fails and the app left something open in the session (a stream it never stopped, a delivery about to be retried), it ends with Still open: ….

Text arguments (text, a string | RegExp) match a string by substring and a RegExp by test. An author (AuthorRef) is a handle, matched by id, or a string, matched against the name or the id.

Text matchers read the transcript (for example SlackTranscript): what a person would see, not raw payloads.

Any transcript#

toContainText#

expect(subject).toContainText(text, options?)
Subject
Anything with transcript(): a conversation, thread, message, issue, PR, review comment, Linear comment or session, Notion page or discussion
Arguments and options
text: string | RegExp; from?: AuthorRef, as?: Principal (read as this person: their ephemeral messages included), count?: number, timeout, quietFor
Waits
Polls; with count, quiet then once
Fails with
Expected text matching "…", found <n>. A person sees: and every entry as author: text
Python and Rust
to_contain_text, and not_to_contain_text for the negation

Slack#

toHaveReplyFrom#

expect(subject).toHaveReplyFrom(author, options?)
Subject
SlackThread, or a SlackConversation (a DM: everything in it, threads included)
Arguments and options
author: AuthorRef; text?: string | RegExp, timeout
Waits
Polls
Fails with
Expected a reply from <name> matching "…". The thread has: and every reply
Python and Rust
to_have_reply_from, and not_to_have_reply_from for the negation

toHaveRepliesFrom#

expect(subject).toHaveRepliesFrom(author, options)
Subject
SlackThread or SlackConversation
Arguments and options
author: AuthorRef; count: number (required), text?, timeout, quietFor
Waits
Quiet, then once
Fails with
Expected exactly <n> replies from <name>, found <m>: and the matching replies
Python and Rust
to_have_replies_from, and not_to_have_replies_from for the negation

toGoQuiet#

expect(subject).toGoQuiet(options)
Subject
A thread or a conversation (replies() or transcript()), or anything with comments(): a GitHub or Linear issue, a pull request, a Notion discussion
Arguments and options
maxReplies: number (required), within (default: the timeout), quietFor
Waits
Quiet, then once: it counts the app messages since a person last wrote, those before the check included (decision 0027)
Fails with
Expected the conversation to go quiet within <within> with at most <n> app messages since a person last wrote., whether it went quiet or was still busy, and the apps in turn: my-agent → coder → …
Python and Rust
to_go_quiet(max_replies=…); Rust's to_go_quiet(n) on threads and conversations

toHaveChannelMessageFrom#

expect(subject).toHaveChannelMessageFrom(author, options?)
Subject
SlackConversation
Arguments and options
author: AuthorRef; timeout, quietFor. Top-level messages only, outside any thread
Waits
Polls
Fails with
Expected a message from <name> in the channel itself, found none; under .not, the messages found
Python and Rust
to_have_channel_message_from, and not_to_have_channel_message_from for the negation

toHaveStreamingReplyFrom#

expect(subject).toHaveStreamingReplyFrom(author?, options?)
Subject
SlackThread or SlackConversation
Arguments and options
author?: AuthorRef (anyone if left out); timeout
Waits
Polls
Fails with
Expected a reply being streamed by <name>. The thread has: and each message with its stream state
Python and Rust
to_have_streaming_reply_from, and not_to_have_streaming_reply_from for the negation

toHaveStatus#

expect(subject).toHaveStatus(state, options?)
Subject
SlackThread
Arguments and options
state: "working" | "streaming" | "stopped" | "idle"; timeout
Waits
Polls
Fails with
Expected the thread to be <state>, it is <state> ("<status line>")
Python and Rust
to_have_status, and not_to_have_status for the negation

toHaveStatusText#

expect(subject).toHaveStatusText(text, options?)
Subject
SlackThread
Arguments and options
text: string | RegExp (the assistant.threads.setStatus line); timeout
Waits
Polls
Fails with
Expected the status line to match "…", it is "…" or there is none
Python and Rust
to_have_status_text, and not_to_have_status_text for the negation

toHaveButton#

expect(subject).toHaveButton(label, options?)
Subject
SlackMessage; or a SlackThread or SlackConversation (the app's latest message there)
Arguments and options
label: string | RegExp; timeout
Waits
Polls
Fails with
Expected a button matching "…". Buttons there: and the labels, or none
Python and Rust
to_have_button, and not_to_have_button for the negation

toHaveReaction#

expect(subject).toHaveReaction(emoji, options?)
Subject
SlackMessage
Arguments and options
emoji: string (":eyes:" or "eyes"); by?: AuthorRef, timeout
Waits
Polls
Fails with
Expected a :eyes: reaction by <name>. Reactions there: and each with who added it
Python and Rust
to_have_reaction, and not_to_have_reaction for the negation

toHaveOpenedModal#

expect(subject).toHaveOpenedModal(title?, options?)
Subject
SlackUser
Arguments and options
title?: string | RegExp; timeout. A modal opened for this person, submitted or not
Waits
Polls
Fails with
Expected a modal titled "…" to have been opened. Opened: and the titles, or none
Python and Rust
to_have_opened_modal, and not_to_have_opened_modal for the negation

toBeEphemeralFor#

expect(subject).toBeEphemeralFor(user)
Subject
SlackMessage
Arguments and options
user: SlackUser
Waits
Doesn't wait: reads visibleTo once
Fails with
Expected the message to be visible only to <name>, everyone can see it (or only <name> can)
Python and Rust
to_be_ephemeral_for, and not_to_be_ephemeral_for for the negation

Live, toHaveStatus, toHaveStatusText and toHaveOpenedModal read what needs proxy mode, which live doesn't read back yet (#24), so they skip the test (action_requires).

Comments: GitHub, Linear, Notion#

toHaveCommentFrom#

expect(subject).toHaveCommentFrom(author, options?)
Subject
Anything with comments(): GitHubIssue, GitHubPullRequest, LinearIssue, NotionDiscussion
Arguments and options
author: AuthorRef; text?: string | RegExp, timeout
Waits
Polls
Fails with
Expected a comment from <name> matching "…". The conversation has: and every comment
Python and Rust
to_have_comment_from, and not_to_have_comment_from for the negation

toHaveCommentsFrom#

expect(subject).toHaveCommentsFrom(author, options)
Subject
The same
Arguments and options
author: AuthorRef; count: number (required), timeout, quietFor
Waits
Quiet, then once
Fails with
Expected exactly <n> comments from <name>, found <m>: and every comment
Python and Rust
to_have_comments_from, and not_to_have_comments_from for the negation

A NotionPage has no comments(): check one of its discussions().

GitHub#

toHaveReviewComment#

expect(subject).toHaveReviewComment(expected, options?)
Subject
GitHubPullRequest
Arguments and options
expected: { path?: string; line?: number; from?: AuthorRef; text?: string | RegExp }, every given field must match; timeout
Waits
Polls
Fails with
Expected a comment on the diff on <path>:<line> from <name> matching "…". The diff has: and each as author on path:line: body
Python and Rust
to_have_review_comment, and not_to_have_review_comment for the negation

toHaveReviewFrom#

expect(subject).toHaveReviewFrom(author, options?)
Subject
GitHubPullRequest
Arguments and options
author: AuthorRef; state?: "COMMENTED" | "APPROVED" | "CHANGES_REQUESTED", timeout
Waits
Polls
Fails with
Expected a review from <name> with state <state>. Reviews there: and each with its state
Python and Rust
to_have_review_from, and not_to_have_review_from for the negation

toHaveCheckRun#

expect(subject).toHaveCheckRun(name, options?)
Subject
GitHubPullRequest (its newest commit) or GitHubCommit
Arguments and options
name: string | RegExp (a string must equal the name); status?: "queued" | "in_progress" | "completed", conclusion?: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required", timeout
Waits
Polls
Fails with
Expected a check run "…" (<status>, <conclusion>). Check runs there: and each with status and conclusion
Python and Rust
to_have_check_run, and not_to_have_check_run for the negation

toHaveLabel#

expect(subject).toHaveLabel(name, options?)
Subject
GitHubIssue or GitHubPullRequest (also a LinearIssue)
Arguments and options
name: string, compared case-insensitively; timeout
Waits
Polls
Fails with
Expected the label "…". Labels there: and the labels, or none
Python and Rust
to_have_label, and not_to_have_label for the negation

toBeMerged#

expect(subject).toBeMerged(options?)
Subject
GitHubPullRequest
Arguments and options
timeout
Waits
Polls
Fails with
Expected the pull request to be merged
Python and Rust
to_be_merged, and not_to_be_merged for the negation

Live, the reads behind toHaveReviewComment, toHaveReviewFrom, toHaveCheckRun and toBeMerged aren't built yet, so they skip the test (unsupported_in_live).

Linear#

toHaveSessionState#

expect(subject).toHaveSessionState(state, options?)
Subject
LinearAgentSession, or a LinearIssue (its latest session)
Arguments and options
state: "pending" | "active" | "awaitingInput" | "complete" | "error" | "stale"; timeout
Waits
Polls
Fails with
Expected the agent session to be <state>, it is <state> (no session when the issue has none)
Python and Rust
to_have_session_state, and not_to_have_session_state for the negation

toHaveActivity#

expect(subject).toHaveActivity(expected, options?)
Subject
LinearAgentSession or LinearIssue (its latest session)
Arguments and options
expected: { type?: "thought" | "action" | "elicitation" | "response" | "error"; from?: AuthorRef; text?: string | RegExp }, every given field must match; timeout. People's prompts don't count
Waits
Polls
Fails with
Expected a <type> from <name> matching "…". The session has: and each as author (type): body
Python and Rust
to_have_activity, and not_to_have_activity for the negation

toBeAssignedTo#

expect(subject).toBeAssignedTo(user, options?)
Subject
LinearIssue
Arguments and options
user: Principal | undefined (undefined: no one), compared by id; timeout
Waits
Polls
Fails with
Expected the issue to be assigned to <name>, it is assigned to <name> (or no one)
Python and Rust
to_be_assigned_to, and not_to_be_assigned_to for the negation

toBeDelegatedTo#

expect(subject).toBeDelegatedTo(app, options?)
Subject
LinearIssue
Arguments and options
app: Principal | undefined (undefined: none), compared by id; timeout
Waits
Polls
Fails with
Expected the issue to be delegated to <name>, it is delegated to <name> (or no one)
Python and Rust
to_be_delegated_to, and not_to_be_delegated_to for the negation

toHaveState#

expect(subject).toHaveState(name, options?)
Subject
LinearIssue
Arguments and options
name: string, the workflow state's name, compared case-insensitively; timeout
Waits
Polls
Fails with
Expected the issue to be in "…", it is in "…"
Python and Rust
to_have_state, and not_to_have_state for the negation

Notion#

toHaveBlock#

expect(subject).toHaveBlock(text, options?)
Subject
NotionPage
Arguments and options
text: string | RegExp, matched against each block's text at any depth (a child page's title counts); timeout
Waits
Polls
Fails with
Expected the page to have a block matching "…". Its blocks: and each block's text
Python and Rust
to_have_block, and not_to_have_block for the negation

toHavePropertyValue#

expect(subject).toHavePropertyValue(name, value, options?)
Subject
NotionPage (a database row)
Arguments and options
name: string, value: unknown, compared with Vitest's equality, so asymmetric matchers (expect.any(Number)) work; timeout
Waits
Polls
Fails with
Expected <name> to be <value>, it is <value>
Python and Rust
to_have_property_value, and not_to_have_property_value for the negation

Live, toHavePropertyValue reads a property, which isn't built live yet: it skips the test (unsupported_in_live).

Deliveries#

Subject: any delivery (SlackDelivery, GitHubDelivery, LinearDelivery, NotionDelivery). They read refresh(), which is fake only except on GitHub; live elsewhere they skip the test (unsupported_in_live).

toBeAccepted#

expect(subject).toBeAccepted(options?)
Subject
A delivery
Arguments and options
within?: Duration (also require durationMs <= within), timeout. Reads the first attempt that wasn't forged
Waits
Polls
Fails with
Expected delivery <id> to be accepted within <n>ms, its first attempt is <status> (HTTP <code>) after <n>ms
Python and Rust
to_be_accepted, and not_to_be_accepted for the negation

toBeRejected#

expect(subject).toBeRejected(options?)
Subject
A delivery that was resent forged (resend({ badSignature: true }) or { stale: true })
Arguments and options
timeout. Reads the latest forged attempt: it must be failed with a 4xx
Waits
Polls
Fails with
Expected the forged attempt of delivery <id> to be rejected with a 4xx, the agent answered <code>; with no forged attempt, … but no forged attempt was sent. Call delivery.resend({ badSignature: true }) first
Python and Rust
to_be_rejected, and not_to_be_rejected for the negation

toBeRetried#

expect(subject).toBeRetried(options?)
Subject
A delivery
Arguments and options
times?: number (exact), timeout, quietFor. Counts attempts that weren't forged, minus the first
Waits
Polls; with times, quiet then once
Fails with
Expected delivery <id> to be retried <n> times, it was retried <m> times
Python and Rust
to_be_retried, and not_to_be_retried for the negation

API calls#

toHaveReceivedCall#

expect(subject).toHaveReceivedCall(operation, options?)
Subject
A channel fixture (slack, github, linear, notion, …), or openai, whose calls are named by their endpoint (chat.completions, responses)
Arguments and options
operation: string | RegExp (a string must equal the operation, or the model call's endpoint); error?: string (only calls that returned this error), times?: number (exact), timeout, quietFor
Waits
Polls; with times, quiet then once
Fails with
Expected the agent to call "…" <n> times with error <code>, found <m>. Its calls: and each as operation → error
Python and Rust
to_have_received_call, and not_to_have_received_call for the negation

It reads calls(), so live it needs proxy mode, which doesn't read the app's calls back live yet (#24): the test is skipped (action_requires).

The model#

The fake OpenAI's matchers read what your agent sent the model and how each script answered. Their subjects are the openai fixture (every model call of the test), a script (what openai.respond(…) returned: the calls it answered), or one call (OpenAICall, from openai.latestCall() or ai.waitForPause()). An unscripted model call fails a waiting matcher at once, with the openai.respond(…) that would have answered it.

toHaveSent#

expect(subject).toHaveSent(expected, options?)
Subject
openai, a script, or a call
Arguments and options
expected: a string, a RegExp, something with text (a message, a comment, an email), or a list of them; ordered?: boolean (default true for a list: they appear in that order in one call, as thread history does), timeout, quietFor
Waits
Polls; under .not, quiet then once
Fails with
Expected the agent to send the model "…", then "…" in that order. What it sent, newest first: and each call's text, or It made no model call.
Python and Rust
to_have_sent, and not_to_have_sent for the negation

expect(openai).not.toHaveSent(privateMessage) checks that no text from a channel the agent shouldn't read reached the model.

toHaveSentSecrets#

expect(openai).not.toHaveSentSecrets(options?)
Subject
openai
Arguments and options
timeout, quietFor. Use it under .not
Waits
Quiet, then once
Fails with
Expected the agent not to send the model any secret, it sent: and each call with the kinds it carried (slack.botToken), never their values
Python and Rust
to_have_sent_secrets, and not_to_have_sent_secrets for the negation

A secret is any token, signing secret, webhook secret, private key or refresh token channelstack knows, fake or live, and the model's own API key in the body.

toHaveOfferedTool#

expect(subject).toHaveOfferedTool(name, options?)
Subject
openai, a script, or a call
Arguments and options
name: string, the tool's name; schema? (the tool's JSON Schema parameters must equal it), timeout
Waits
Polls
Fails with
Expected the agent to offer the model the tool "…", it offered <names>, or none
Python and Rust
to_have_offered_tool

toHaveSentToolResult#

expect(subject).toHaveSentToolResult(name, options?)
Subject
openai, or a script
Arguments and options
name: string, the tool the model called; text?: string | RegExp (the result the agent sent back must match), timeout
Waits
Polls
Fails with
Expected the agent to send back a result for "…" with …. The model called it <n> times; <m> got a result: and each result
Python and Rust
to_have_sent_tool_result

toHaveSentFile#

expect(subject).toHaveSentFile(file, options?)
Subject
openai, a script, or a call
Arguments and options
file: string | Uint8Array, a path read in the test process (from the test file's directory) or the bytes themselves; timeout
Waits
Polls
Fails with
Expected the agent to send the model <file> (<size>, sha256 <hash>). and the images, files and audio it did send, newest first, or It sent no image, file or audio.
Python and Rust
to_have_sent_file

It compares the SHA-256 of what the agent sent as an image, file or audio part, on either endpoint or a media endpoint's upload, with the file's.

toBeAborted#

expect(call).toBeAborted(options?)
Subject
A model call
Arguments and options
timeout
Waits
Polls call.refresh()
Fails with
Expected model call <id> to be aborted by the agent, it is still going, or it ended <how> (completed, errored, dropped, stalled)
Python and Rust
to_be_aborted

It holds when the agent hung up before the answer was complete: it cancelled the request (Stop) or timed out.

toHaveAnswered#

expect(script).toHaveAnswered(options?)
Subject
A script
Arguments and options
times?: number (exact), timeout, quietFor
Waits
Polls; with times, quiet then once
Fails with
Expected script <id> to answer 2 calls, it answered <n>, and the script's problems, if it has any
Python and Rust
to_have_answered, and not_to_have_answered for the negation

A call counts once the script's turn reached the agent: its answer, or its scripted error. A call the fake refused for the script doesn't count, nor one a responder still holds, nor one the agent hung up on before the first token.

Read methods#

Every matcher is built on a plain read, so a test can read the value itself:

MatcherReads
toContainTexttranscript()
toHaveReplyFrom, toHaveRepliesFrom, toHaveStreamingReplyFromthread.replies(), or a conversation's transcript()
toGoQuietreplies(), transcript() or comments(), and their authors' kind
toHaveChannelMessageFromconversation.messages()
toHaveStatus, toHaveStatusTextthread.status()
toHaveButtonthe transcript entry's controls
toHaveReactionmessage.reactions()
toHaveOpenedModaluser.modals()
toBeEphemeralFormessage.visibleTo
toHaveCommentFrom, toHaveCommentsFromcomments()
toHaveReviewComment, toHaveReviewFrompr.reviewComments(), pr.reviews()
toHaveCheckRuncheckRuns()
toHaveLabelissue.labels()
toBeMergedpr.merged()
toHaveSessionState, toHaveActivitysession.state(), session.activities()
toBeAssignedTo, toBeDelegatedTo, toHaveStateissue.assignee(), issue.delegatedTo(), issue.state()
toHaveBlockpage.blocks()
toHavePropertyValuepage.property(name)
toBeAccepted, toBeRejected, toBeRetrieddelivery.refresh(), then attempts
toHaveReceivedCallfixture.calls()
toHaveSent, toHaveOfferedToolopenai.calls(), script.calls(), or the call itself
toHaveSentSecretsopenai.sentSecrets()
toHaveSentToolResultopenai.toolCalls(), script.toolCalls()
toBeAbortedcall.refresh()
toHaveAnsweredscript.refresh()

A matcher given a subject without the read it needs throws a TypeError, e.g. This matcher needs a thread or a conversation.

Suggest changes to this page