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");await expect(msg.thread).to_have_reply_from("my-agent", text=re.compile("incident", re.I))await expect(msg.thread).to_have_replies_from(slack.app, count=1)await expect(channel).not_to_have_channel_message_from("my-agent")expect(&msg.thread()) .to_have_reply_from("my-agent") .text(Regex::new("(?i)incident")?) .await?;expect(&msg.thread()) .to_have_replies_from(&slack.app(), 1) .await?;expect(&channel) .not_to_have_channel_message_from("my-agent") .await?;How they wait#
Every matcher is async: await it.
| Kind | Waits | Then |
|---|---|---|
| Positive | Polls (every 50ms) until the condition holds | Passes as soon as it holds; fails at timeout |
Negative (.not) | Until the app has been quiet for quietFor, watching for the whole window | Checks once |
Exact count (count, times) | Until the app has been quiet for quietFor, watching for the whole window | Checks 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.
| Option | Type | Default | On |
|---|---|---|---|
timeout | Duration | The plugin's timeout (10s) | Every matcher but toBeEphemeralFor |
quietFor | Duration | The 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 asauthor: text- Python and Rust
to_contain_text, andnot_to_contain_textfor the negation
Slack#
toHaveReplyFrom#
expect(subject).toHaveReplyFrom(author, options?)
- Subject
SlackThread, or aSlackConversation(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, andnot_to_have_reply_fromfor the negation
toHaveRepliesFrom#
expect(subject).toHaveRepliesFrom(author, options)
- Subject
SlackThreadorSlackConversation- 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, andnot_to_have_replies_fromfor the negation
toGoQuiet#
expect(subject).toGoQuiet(options)
- Subject
- A thread or a conversation (
replies()ortranscript()), or anything withcomments(): 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'sto_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, andnot_to_have_channel_message_fromfor the negation
toHaveStreamingReplyFrom#
expect(subject).toHaveStreamingReplyFrom(author?, options?)
- Subject
SlackThreadorSlackConversation- 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, andnot_to_have_streaming_reply_fromfor 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, andnot_to_have_statusfor the negation
toHaveStatusText#
expect(subject).toHaveStatusText(text, options?)
- Subject
SlackThread- Arguments and options
text: string | RegExp(theassistant.threads.setStatusline);timeout- Waits
- Polls
- Fails with
Expected the status line to match "…", it is "…"orthere is none- Python and Rust
to_have_status_text, andnot_to_have_status_textfor the negation
toHaveButton#
expect(subject).toHaveButton(label, options?)
- Subject
SlackMessage; or aSlackThreadorSlackConversation(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, ornone- Python and Rust
to_have_button, andnot_to_have_buttonfor 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, andnot_to_have_reactionfor 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, ornone- Python and Rust
to_have_opened_modal, andnot_to_have_opened_modalfor the negation
toBeEphemeralFor#
expect(subject).toBeEphemeralFor(user)
- Subject
SlackMessage- Arguments and options
user: SlackUser- Waits
- Doesn't wait: reads
visibleToonce - Fails with
Expected the message to be visible only to <name>, everyone can see it(oronly <name> can)- Python and Rust
to_be_ephemeral_for, andnot_to_be_ephemeral_forfor 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, andnot_to_have_comment_fromfor 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, andnot_to_have_comments_fromfor 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 asauthor on path:line: body- Python and Rust
to_have_review_comment, andnot_to_have_review_commentfor 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, andnot_to_have_review_fromfor the negation
toHaveCheckRun#
expect(subject).toHaveCheckRun(name, options?)
- Subject
GitHubPullRequest(its newest commit) orGitHubCommit- 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, andnot_to_have_check_runfor the negation
toHaveLabel#
expect(subject).toHaveLabel(name, options?)
- Subject
GitHubIssueorGitHubPullRequest(also aLinearIssue)- Arguments and options
name: string, compared case-insensitively;timeout- Waits
- Polls
- Fails with
Expected the label "…". Labels there:and the labels, ornone- Python and Rust
to_have_label, andnot_to_have_labelfor 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, andnot_to_be_mergedfor 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 aLinearIssue(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 sessionwhen the issue has none)- Python and Rust
to_have_session_state, andnot_to_have_session_statefor the negation
toHaveActivity#
expect(subject).toHaveActivity(expected, options?)
- Subject
LinearAgentSessionorLinearIssue(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 asauthor (type): body- Python and Rust
to_have_activity, andnot_to_have_activityfor the negation
toBeAssignedTo#
expect(subject).toBeAssignedTo(user, options?)
- Subject
LinearIssue- Arguments and options
user: Principal | undefined(undefined: no one), compared byid;timeout- Waits
- Polls
- Fails with
Expected the issue to be assigned to <name>, it is assigned to <name>(orno one)- Python and Rust
to_be_assigned_to, andnot_to_be_assigned_tofor the negation
toBeDelegatedTo#
expect(subject).toBeDelegatedTo(app, options?)
- Subject
LinearIssue- Arguments and options
app: Principal | undefined(undefined: none), compared byid;timeout- Waits
- Polls
- Fails with
Expected the issue to be delegated to <name>, it is delegated to <name>(orno one)- Python and Rust
to_be_delegated_to, andnot_to_be_delegated_tofor 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, andnot_to_have_statefor 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, andnot_to_have_blockfor 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, andnot_to_have_property_valuefor 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 requiredurationMs <= 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, andnot_to_be_acceptedfor 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 befailedwith 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, andnot_to_be_rejectedfor 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, andnot_to_be_retriedfor the negation
API calls#
toHaveReceivedCall#
expect(subject).toHaveReceivedCall(operation, options?)
- Subject
- A channel fixture (
slack,github,linear,notion, …), oropenai, 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 asoperation → error- Python and Rust
to_have_received_call, andnot_to_have_received_callfor 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: astring, aRegExp, something withtext(a message, a comment, an email), or a list of them;ordered?: boolean(defaulttruefor 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, orIt made no model call.- Python and Rust
to_have_sent, andnot_to_have_sentfor 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, andnot_to_have_sent_secretsfor 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>, ornone- 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, orIt 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, orit 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, andnot_to_have_answeredfor 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:
| Matcher | Reads |
|---|---|
toContainText | transcript() |
toHaveReplyFrom, toHaveRepliesFrom, toHaveStreamingReplyFrom | thread.replies(), or a conversation's transcript() |
toGoQuiet | replies(), transcript() or comments(), and their authors' kind |
toHaveChannelMessageFrom | conversation.messages() |
toHaveStatus, toHaveStatusText | thread.status() |
toHaveButton | the transcript entry's controls |
toHaveReaction | message.reactions() |
toHaveOpenedModal | user.modals() |
toBeEphemeralFor | message.visibleTo |
toHaveCommentFrom, toHaveCommentsFrom | comments() |
toHaveReviewComment, toHaveReviewFrom | pr.reviewComments(), pr.reviews() |
toHaveCheckRun | checkRuns() |
toHaveLabel | issue.labels() |
toBeMerged | pr.merged() |
toHaveSessionState, toHaveActivity | session.state(), session.activities() |
toBeAssignedTo, toBeDelegatedTo, toHaveState | issue.assignee(), issue.delegatedTo(), issue.state() |
toHaveBlock | page.blocks() |
toHavePropertyValue | page.property(name) |
toBeAccepted, toBeRejected, toBeRetried | delivery.refresh(), then attempts |
toHaveReceivedCall | fixture.calls() |
toHaveSent, toHaveOfferedTool | openai.calls(), script.calls(), or the call itself |
toHaveSentSecrets | openai.sentSecrets() |
toHaveSentToolResult | openai.toolCalls(), script.toolCalls() |
toBeAborted | call.refresh() |
toHaveAnswered | script.refresh() |
A matcher given a subject without the read it needs throws a TypeError, e.g. This matcher needs a thread or a conversation.