Skip to content

Workflow tests

A workflow test file describes what people do in your application and what the application stores. The file ends in .mtdtest and lives in tests/ beside your .mtd files. The compiler, the deployment and the canonical model never read it. To write a first test, follow Test a workflow of your app. To see why the tests are reliable, read How workflow tests run.

A file holds exactly one suite. The lexical rules are those of .mtd (see Lines, lists and messages): a line ends a statement, // starts a comment, and quoted text uses double quotes. Nothing in the language is a reserved word.

suite "<name>" {
seed: <directory>
clock: <timestamp>
locale: <locale>
dev: true | false
user <name> { … }
test "<name>" { <step> … }
}

A suite sets four optional properties, each at most once, and then holds users and tests. It holds at least one test.

Property Meaning Default
seed: The directory of CSV files that the tenant starts with. It is read like matterdata install -seed. The path is relative to the application and stays inside it. seed
clock: The time of every request, in the stored form: UTC, with seconds and a Z. Write 2026-09-30T10:00:00Z. 2026-01-05T09:00:00Z
locale: The language of every request, and the notation of the values in fill. It is a locale of the application. the language of the application
dev: true runs the application in development mode and prints a note. The default runs it as it is deployed. false

Read Load demo data and bind logins to records for the seed files. A suite without a seed: line uses seed/ when the directory exists. A suite that names a directory without CSV files fails before the first test.

suite "Editorial workflow" {
seed: seed
clock: 2026-09-30T10:00:00Z
locale: en

A user is a login that the tests can act as. The runner creates every user once per suite.

user writer {
email: "writer@news.example"
roles: author
profile person = 1
}
Line Meaning
email: The address of the login. It is required and unique in the suite.
roles: One or more roles of the application. It is required.
locale: The language of this user’s requests. It replaces the locale: of the suite for this user.
profile <name> = <id> Binds the profile to the row with that id, like install -login. The row must exist in the seed.

The name of a user is a plain name, unique in the suite, and never anonymous. Every user has the same password, workflow-test-password. The tenant exists only for one test.

A test starts with its own copy of the seeded tenant and shares nothing with another test. It starts with as.

Step What it does
as <user> Signs in as the user, through the login form of the engine.
as anonymous Sends no session.
sign out Presses the sign-out button of the account menu as the user on screen. The session ends on the server, and the user is anonymous. See Sign out.
open <page> Requests a page that has no route parameter.
open <page>.new Requests the page at its new_route:.
open <page>.new(<row>) Requests the page at a new_route: that carries scope parameters. See Open a create page beneath a scope.
open <page>.new copying <name> Requests the create page with the bound row read into it, as “Copy as template” does. See Copy a row as a template.
open <page>(<row>) Requests the page of one row. See Address a row.
open <page> from <page> Requests the page as a click on a link of the second page, which the engine does not redirect to a language. If the second page is on the screen, it must draw the link. See Click a link.
fill <table> { <field>: <value> … } Sets controls of the form of that table on the open page.
fill <table> anyway { … } The same. If the page drew no form of that table for this user, it sends the save that the form would send. See Send a save that the page did not draw.
fill <table> in region <test_id> [anyway] { … } The same, for the form whose region has that test_id:. See Choose the form of a fill.
fill <table> { <field>: file "<path>" } Chooses a file in the file or img control of the form. The file is next to the suite. See Attach a file.
fill <table> { <field>: remove file } Ticks the box that removes the stored file of a file or img control. See Remove a stored file.
sheet <table> { row <name> { <column>: <value> … } … } Names the rows of the open page’s sheet of that table and the cells that each one sets. See Save a sheet.
sheet <table> anyway { … } The same. A row that the sheet does not list for this user is sent with a stamp of no row. See Save a sheet.
submit [save | delete] [as <name>] Sends the form, or the save of the sheet. save is the default.
submit delete in region <test_id> Sends the delete of the form whose region has that test_id:. See Choose the form of a delete.
submit delete [in region <test_id>] anyway The same. If the page drew no form for this user, it sends the delete that the form would send. See Send a delete that the page did not draw.
download <name>.<field> Requests the stored file of the row that <name> is bound to, as the user on screen. See Download a stored file.
download <name>.<field> with token <name>.<column> The same, with the token of a row in the address, as a page routed by that token writes it. See Download a file with a token.
choose <scope> = <name> Picks the row that <name> is bound to in the scope selector of the page header, as the user on screen. See Choose a scope.
run transition <name> Moves the row of the open page along a transition of its lifecycle.
expect … An outcome, a database assertion or a page assertion.

open, submit, download, choose and run are each followed by exactly one outcome expect. as and sign out are followed by none. A fill, a submit or a run needs an open of the same user whose outcome was expect ok. After a submit or a run, the page is finished: open it again for the next form step. The one exception is expect invalid, which leaves the form on the screen. Then a second fill and submit continue. expect rejected finishes the page too, and so does a run that ends in refused: a second fill, submit or run on the same open is refused before the test runs, and the repair says to open the page again.

as writer
open newsroom_post_new
expect ok
fill posts {
title: "Club news"
body: "Training starts on Monday."
}
submit
expect saved

The parentheses of open take one positional argument, or only named arguments, one for each route parameter.

Write Meaning
open post(article) A name bound earlier. See Bind a row to a name.
open post(3) A row id, when the route binds the id.
open post("club-news") A slug or a token, when the route binds one.
open post(article.slug) A stored column of a bound row.
open grades(course: 3, grade: g) Every route parameter, named.

The engine derives the address from your routes. A test never writes a URL.

A new_route: can carry the earlier parameters of the page’s route:, such as /courses/{course}/grades/new for a page at /courses/{course}/grades/{grade}. Each of these parameters is a scope: the row of that scope’s table that the new row will belong to. Write them in the parentheses of .new, in the same way as for any other page:

open grade.new(course)
open grade.new(course: 3)
open note.new(course: c, term: t)
  • A create page has no row of its own, so there is nothing to derive a parameter from. One parameter takes one positional argument. Two or more must all be named.
  • Each argument is the row of the scope’s table: a name bound to a row of that table, a column of a bound row, or a row id. A name bound to a row of another table, even the table of the page itself, is refused before the test runs.
  • Name only the parameters that the new_route: carries. A page whose new_route: has no parameter takes no parentheses.

The engine checks the scope row when it opens the page, and again when it saves the form. A scope row that does not exist, that is in a gone state, or that the user cannot choose is expect missing, as for any row that is not there. Fill the form and submit as for any create page; submit … as <name> binds the new row. Then show that the row carries the scope with expect row.

A form with actions: save, delete, duplicate offers a link, “Copy as template” by default. The link opens the create page with the values of the row on screen. open <page>.new copying <name> makes the same request. <name> is a row that an earlier step bound. The step ends in an outcome like any open, and after expect ok the create form is on the screen. Fill the controls that the copy left empty, and submit as for any create page.

open shift.new copying welcome
expect ok
submit
expect invalid starts_at
fill shifts {
starts_at: "2100-12-01 09:00"
ends_at: "2100-12-01 12:00"
}
submit as next_year
expect saved

The shift form says clear: starts_at, ends_at, so the copy has no dates and the first submit is invalid. The second submit saves a new row. Show with expect row what the copy carried, and that the row that you copied is as it was.

The rules of the step:

  • The engine builds the address: the new_route: of the page and the query parameter of its copy link. The runner only supplies the token of the bound row, in the column that the route of the page uses (id, a slug or a token). A test never writes the address.
  • The page must have a form that lists duplicate in actions:. The name must be bound before the step, and it must be a row of the table that the page is about. The validator refuses a page without a duplicate, an unbound name, a row of another table, copying after a name without .new, and parentheses after .new. A page that offers a duplicate has no scope parameter.
  • The engine decides who may copy and which row. A page that the user’s role does not reach is refused or login. A copy that a duplicate { access: … } block withholds, a row that the user may not see, a row that is deleted and a row that does not exist are all missing: the engine answers 404 for each, so that the answer does not say which one it was. A page with no duplicate would also answer missing, and the validator refuses it first.
  • The copy fills the controls of the form and nothing else. It does not carry a lifecycle state, a slug, an unguessable, a column that the engine writes, a readonly: field, a picture, a column that is unique alone, a column in clear:, or a sensitive column that the user is not granted. A column that belongs to a composite unique(…) is carried. Assert the saved row, because this step cannot read a control: see Project status.
  • A bound row is the row as it was when the name was bound. A test can delete the row and then copy the name to see the missing.
  • After expect ok the page is open as a create page: fill, submit and submit … as <name> work as for open <page>.new. submit delete is refused, because a create page has no row.
as helper
expect row shifts where title = "Open welcome desk" as welcome
open shift.new copying welcome
expect refused
as anonymous
open shift.new copying welcome
expect login
expect count shifts = 3

A person who clicks a link on a page of the application makes a request that a typed address does not make. The browser tells the engine that the request comes from the site itself. This matters in an application with several languages. The first visit to the unprefixed address of a public page, with another language in the request, is sent to the address of that language. A click on a link of the site is served at the address that it asked for, in the language of the application. open <page> from <page> makes the request of a click. Write the page that you ask for, and then the page that holds the link:

open start from subscribe(mine)
expect ok
expect shows "Upcoming events" in list of events
expect hides "Bevorstehende Events"
expect hides "Events des Königreichs"

The suite has locale: de. The same open start, without from, is a first visit. The engine sends it to /de/, the runner follows that redirect, and the page is the German page. See Open a public page in another language.

A person can click only a link that the page draws. When the page on the screen is the page after from, the runner reads the link in the page that the engine drew. The front page of the calendar draws a button “Create my calendar”, so this click is one that a visitor can make:

open subscribe.new from start
expect ok
expect shows "Save calendar"
expect hides "Kalender speichern"

A click on a link that the page does not draw fails the step before any request. The failure says that the page on screen has no link to the address, and lists the links that the page drew.

The rules of the step:

  • Each page is written as an open writes its page: a name, .new, and the row in parentheses. A row is a bound name, an id or a slug. copying comes before from: open shift.new copying template from shifts. The word from is read by its position, so a page, a table or a bound name can still be called from.
  • The page after from is an address. The check before the first request holds it to a page of the application and to the route of that page, as it holds the first page. It does not ask who may open the page. The step has no outcome for that page.
  • The runner reads the link only when the page after from is the page on the screen. The page on the screen is the page of the last open that ended in expect ok, or the form that a save returned with expect invalid. It is the same page when the page is the same, it is the same create page or row page, and the address is the same: post(first) is not post(second). The language prefix of the engine is taken off before the addresses are compared, so a German page that a first visit opened is still the page start. Then the page that the engine drew must hold an <a href> that leads to the address of the step. Every link of the document counts, the navigation of the header and the footer too. A link is matched by its path. If the address has a query, such as the copy of a copy link, the link must have the same parameters. A link that goes to another site, a mailto: link and a link without an href do not count.
  • In every other case the step is the headers of a click and nothing else. If nothing is on the screen (after a save, a sign-out or an as), if another page is on the screen, or if the same page is on the screen at another address, the runner does not read a link. It sends the request of a click to the address that you name, as before. Open the page that holds the link first when you want the link to be checked.
  • A page that a first visit opened in another language writes its links under the language prefix, such as /de/calendar/new. The address that open writes has no prefix. A click on the unprefixed address is the link of the other language, such as the “English” link of a German page. When the page draws only the prefixed link, the failure names it. A click on a prefixed link is not written yet.
  • The step ends in the outcomes of an open: ok, refused, missing, gone or login. After expect ok the page that you asked for is on the screen.
  • The request carries what a browser sends for a click on a link of the same site: Sec-Fetch-Site: same-origin, Sec-Fetch-Mode: navigate, Sec-Fetch-Dest: document, Sec-Fetch-User: ?1, and the address of the second page as the Referer. The engine reads Sec-Fetch-Site, and the host of the Referer when the first is missing. The runner derives the addresses with the routing of the engine. No other request of a step carries these headers.
  • The runner follows no language redirect for a click. If the engine answers a click with that redirect, the step fails with the 302 and says what it means. expect 302 is not allowed.

fill names the form by its table. The open page must have a form of that table, and a field must be a control of that form, not readonly. When the page has two forms of the table, the user who acts and, if needed, a test_id: choose one. See Choose the form of a fill. A value is the text a person types, in quotes:

Field Write Example
text, long_text, markdown, email the text "Club news"
money, decimal(n) the number in the notation of the locale: "14.50" (English), "14,50" (German)
int digits "90"
date, datetime the spelling a person types, in the locale and the time zone of the application "2026-10-05 09:00"
enum the value "feature"
ref the id of the row "3"
bool true or false, without quotes true
multi several values, separated by commas "1,2"

A ref also takes a bound row instead of an id: volunteer: lena.id. See Use a bound row as a value.

An empty text "" clears a control. A control that you do not name keeps the value the page drew, so hidden fields and the CSRF token travel as they do from a browser. A select takes only a value that it offers. A control that the engine did not draw for this user cannot be filled. A page that draws no form of the table for this user fails the fill, and the failure names the word anyway. See Send a save that the page did not draw.

A fill is sent by the next submit only. A fill that nothing submits is refused. A field in a fill cannot be a lifecycle state (use run transition), a computed or aggregate column, a slug or an unguessable. An img or a file takes a file, not a text. See Attach a file.

A page can hold more than one form of one table. The time entry page of the time tracking example has one form of time_entries for consultants and managers and one for backoffice. A fill is for the form of its table that the page draws to the user who acts:

  • If the user is drawn one of the forms, that is the form. Write nothing more.
  • If the user is drawn more than one, the fill is refused and the repair lists the forms. Give each form a test_id: in the page source and name one: fill <table> in region <test_id> { … }.
  • A fill can always name the form. The test_id must be the id of a form region of that table on the open page. The check before the first request refuses an id that the page does not have (the repair lists the ids of the page and says when the id is on another page), the id of a region of another kind, and the id of a form of another table.
  • If the roles of the user do not admit the named form, the check refuses the fill, unless you write anyway. Write anyway after the region: fill <table> in region <test_id> anyway { … }. It sends the save of a form that the page did not draw, as in Send a save that the page did not draw.
open entry.new
expect ok
fill time_entries in region anybodys_time {
employee: carla
project: reporting
work_date: "2026-09-28"
minutes: "45"
description: "Booked by backoffice"
}
submit
expect saved

The check before the first request knows the roles of the user (as <user> and the roles: of the user) and the role lists in the access: of the page and of the form. It does not know the rows. An access: rule with a where admits the user only for some rows, so the check says nothing and the runner decides with the page that the engine drew. When the runner finds more than one form drawn to the user, it fails the step with the same repair. The controls of a fill are the controls of the chosen form. When the check cannot choose, a control must be on at least one of the candidate forms.

A submit with no fill before it, such as submit delete, sends the form that the page draws to the user, when that is one form. When the page draws two forms to the user, a save names its form in the fill, and a delete names it as shown in the next section.

A delete has no fields, so no fill can name its form. When the page draws two forms of one table to the user, submit delete is refused and the repair lists the ids of the forms. Name one: submit delete in region <test_id>.

The time tracking suite has a login that is backoffice and also a consultant. The time entry page draws both forms to that login. The first delete goes through the form of their own time, and the second through the form of anybody’s time:

open entry(mine)
expect ok
submit delete in region own_time
expect deleted
  • The test_id must be the id of a form region on the open page, and the form must offer delete in its actions:. The check before the first request refuses an id that the page does not have, the id of a region that is not a form, and a form without a delete. It also refuses a form whose roles do not admit the user, and it lists the forms that do. To send a delete for a form that the page does not draw to the user, write anyway (Send a delete that the page did not draw).
  • Only a delete takes in region. A save is sent by the form that its fill named. A sheet step names its table, not a region.
  • The runner finds the region as a fill does. If the page drew neither the save form nor the delete form to the user, the step fails and names anyway. If the page drew the form and withheld the delete button (a delete { access: … } block), the runner sends the request that the button would send and records a note, as it does for a submit delete of a page with one form.

A file or img control takes the file that a person chooses in it. Write file and the path of the file in quotes:

as anna
open my_assignment(poster)
expect ok
fill submissions {
attachment: file "files/report.pdf"
}
submit
expect saved
expect row submissions where assignment = poster.id and student = student_anna.id {
answer: empty
status: draft
attachment_filename: "report.pdf"
attachment_mime: "application/pdf"
attachment_bytes: 580
} as handin

The rules of the value:

  • The path is relative to the directory of the suite file. Keep the files in tests/files/. The path uses forward slashes. It is not empty, not absolute, and has no .. and no backslash. files//a.pdf and ./a.pdf are refused: write the plain form.
  • The file is a regular file of at most 2 MiB. An empty file is allowed, because the engine refuses it and a test of that refusal needs one. The command looks for every file before the first request. A missing file, a directory and a file that is too large are errors at the path. A symbolic link that points outside the directory of the suite is an error too: a suite reads files next to itself and no others.
  • A control takes one file. A text, true, false or a bound row is refused for a file or img control. A file "…" is refused for every other control. To remove a stored file, see Remove a stored file.
  • The request is multipart/form-data, as a browser sends a form with a chosen file. A control with no file chosen sends nothing, so an edit that chooses no file keeps the stored file. With fill … anyway on a form the page did not draw, the file travels in the body that the runner sends.

The engine decides what the file is. It reads the type from the bytes and never from the name. It stores a PDF as it arrived and writes a photograph again. It refuses a type that the column does not accept, an empty file, a file larger than max_mb and a file that passes the storage quota of the tenant. Each refusal marks the file control, so the outcome is expect invalid <field>. Nothing is stored, the form stays on the screen, and the next fill can choose another file:

fill submissions {
attachment: file "files/not-a-pdf.pdf"
}
submit
expect invalid attachment
expect none submissions where assignment = poster.id

A rule of the table about the file reads the row with the file in it. The school rule “write an answer or attach a file” is met by a file alone.

The engine keeps facts about a file in columns of the row. For a field attachment they are attachment_filename, attachment_mime and attachment_bytes. An img also has _width and _height. Assert them in a block, read them in a where, or read them from a bound row. The name is the name that the engine stored, with the extension of the type that it found. An img optimized is stored as a JPEG whatever it was:

expect row events where title = "Quiz night" {
image_filename: "photo.jpg"
image_mime: "image/jpeg"
image_width: 8
image_height: 6
}

The column with the name of the field itself holds the address of the stored bytes. It is not asserted. Write attachment_filename: empty to say that no file is stored.

An edit form draws a box beside the file that a row stores. A person ticks the box and saves, and the engine clears the file. Write remove file as the value of the control:

open payment(twelve)
expect ok
fill payments {
receipt: remove file
}
submit
expect saved
expect row payments where id = twelve.id {
amount: 12.00
method: cash
receipt_filename: empty
receipt_mime: empty
receipt_bytes: empty
}

The engine clears the file and the facts that it kept about it: _filename, _mime, _bytes, and for an img also _width and _height. The other fields of the row are what the form sent. The two words are read together, so a field or a binding can still be called remove.

The rules of the value:

  • remove file is the value of a file or img control and of nothing else. It stands alone: it cannot come with file "…" in the same fill, because the engine refuses a request that chooses a file and removes the stored one.
  • The form must draw the box. The engine draws it only when you edit a row that stores a file in that field. The check before the first request refuses remove file on a create page (<page>.new, with or without copying) and for a file that the table requires, because the form of a required file never has the box. A required img has the box. The check cannot know the row, so a fill of a row that stores no file fails when it runs, and the message says that the form draws no box.
  • The request is what a browser sends for a ticked box: the name <field>__remove with the value 1, and the empty part of the file control. With fill … anyway there is no form to read, and the runner sends the same name in the body that it builds.
  • After a removal, download <name>.<field> fails, because the row holds no file and so no address. Assert the absence with <field>_filename: empty.

A rule of the table about the file reads the row without the file. A school-style rule “write an answer or attach a file” refuses the removal of a file that is all the row holds, and the file stays: the outcome is expect rejected and not expect saved.

download <name>.<field> requests the stored file of the row that <name> is bound to. It makes the request that a link to the file makes, as the user on screen. The address is the address that the engine draws. The row decides who may fetch a file, and the pages that show the file decide which rows:

download agm.document
expect ok
as trainer
download agm.document
expect missing

The step ends in expect ok (200, the bytes) or expect missing (404). The engine answers one 404 for a row that does not exist, a row that this user may not see, and a file that no page shows to this user. It never answers 403 or a redirect to the login page. A file that only the board’s page shows is a 404 for the trainer. The step does not read the headers or the bytes of the response. The step leaves no page on screen: open a page again before the next fill. A row that holds no file has no address, and the step fails. Assert the absence with <field>_filename: empty.

A page can be routed by an unguessable column, such as the preview_token of a post. The page is public, and it shows the one row that holds the token. A file that such a page draws is served only to the holder of the token. The page writes the token into the address of the file as ?mtd_token=<token>. The bare address of the file, which a leaked link has, is a 404. Write with token and a column of a bound row to request the address that the page writes:

download secret.cover
expect missing
download secret.cover with token secret.preview_token
expect ok
download secret.cover with token other.preview_token
expect missing

The rules of the clause:

  • The token is <name>.<column>, the value of a column of a bound row, as the value of a fill is. The column must be an unguessable column of the table of that row. The check before the first request refuses a name that is not bound, a column that does not exist and a column of another kind. The table of the token does not have to be the table of the file: the token of another post is a value that the row does not hold, and the engine answers 404 for it.
  • The runner reads the value of the column from the binding, as open post(secret) reads the token of a route. The engine writes the address and the parameter name. The runner writes neither.
  • with token is only for download. The step ends in expect ok or expect missing, as without the clause.
  • A row that holds no file has no address, and the step fails, as without the clause.

A deny when of a form that already holds when the page opens replaces the form with its sentence. A region access: can also withhold the form from a user. The page then has no form to fill. The engine must still refuse the save whatever the page showed, and fill <table> anyway is how a test proves it.

open public_signup(one)
expect ok
expect count event_signups where event = one.id = 1
fill event_signups anyway {
guest_name: "Jonas Kern"
guest_email: "jonas@example.test"
}
submit
expect rejected "fully booked"
expect none event_signups where guest_email = "jonas@example.test"

The rules of the word:

  • The page must declare a form region of the table, and each field must be a control of that region. The validator checks this before the first request, as for a plain fill. A page with no form of the table is refused.
  • If the page drew the form, anyway changes nothing. The runner fills the drawn form and sends it, with no note.
  • If the page did not draw the form, the runner sends the body that the form would send: the CSRF token of the page, the language and return fields of its other forms, the action save, the number of the form and your values. The request goes to the address of the page, through the same session, CSRF and authorization code as every request. A note under the test records it, as for a transition button that the page did not draw.
  • A control that you do not name is not sent, because no drawn form carries a value for it. Name every control that a required or a rule needs.
  • submit, as <name> and the outcomes are those of a save: saved, invalid, rejected, refused, missing, gone and login. The page is finished afterwards.
  • The engine answers 400 for a form that the role of the user does not admit at all. No outcome word fits 400. Write expect 400 (Check an answer that no word names), and then expect none or expect row to show that nothing was stored. When the status is another, the failure prints it with the reason that the engine logged.

Without anyway, a form that disappears for a reason you did not expect still fails the fill.

The engine draws a delete button only for a user that may delete the row. A test of a refused delete does not need a word for that case: when the form is drawn and only the button is missing, submit delete sends the request that the button would send and records a note. A page can also draw no form of the region to the user at all. A deny when that holds replaces the form with its sentence. A region access: can leave the user out. A submit delete then fails, and anyway is how a test proves that the write refuses the delete. The time entry page draws one form to a consultant and another to backoffice. A consultant does not get the form of backoffice, and a delete that is sent to it is still refused:

as consultant
expect row time_entries where employee = 4 and days_since(work_date) = 0 and minutes = 120 as mine
open entry(mine)
expect ok
submit delete in region anybodys_time anyway
expect 400
expect row time_entries where id = mine.id { minutes: 120 }

The rules of the word:

  • anyway belongs to a delete. A save is sent anyway by its fill and a sheet by its sheet step. submit anyway and submit save anyway are refused. Write it after the region and before as: submit delete in region <test_id> anyway.
  • The check before the first request is the one of submit delete in region <test_id>: the id is a form of the page, and it offers delete. It does not refuse a form whose roles do not admit the user, because that is the case that anyway is for. The word does not choose between two forms. When the page draws more than one form to the user, name the form.
  • If the page drew the delete form, anyway changes nothing. The runner sends the drawn form, with no note. If the page drew the form but not its delete button, the runner sends the request of the button and records the note of a withheld button.
  • If the page drew neither the save form nor the delete form of the region, the runner sends the body that the delete form would send: the CSRF token of the page, the language and return fields of its other forms, the action delete and the number of the region. The request goes through the same session, CSRF and authorization code as every request. A note under the test records it: page <page> drew no form of table <table> for <user>; sent the request the delete form would send.
  • A plain submit delete for a form that the page did not draw fails and says to write anyway.
  • The outcomes are those of a delete. A deny when that holds answers rejected with its sentence. A region that the role of the user does not admit answers 400, and expect 400 is the word. After the step, expect row or expect none shows that the row stayed.

A sheet region is a grid with JavaScript, and its only save is the JSON that the grid sends. A fill has no form to read. sheet <table> { … } names the rows that the grid would send and the cells that it would change. The next submit sends them in one request. The save is one transaction: the engine writes every row or none.

open roster
expect ok
sheet assignments {
row anna_welcome { status: "cancelled" }
row sam_welcome { status: "confirmed" }
row alex_welcome { status: "confirmed" }
}
submit
expect saved

The shift needs two volunteers. Anna gives up her place, so Sam and Alex fit.

  • A row is row <name> { … }. The name is a row that an earlier step bound, as in Address a row. The grid names a row by its id, and the runner reads the id from the bound row. A row of another table, a name that is not bound and a name written twice are refused before the test runs.
  • A cell is written as a control of a fill: a quoted text, true or false for a checkbox, "" to clear, or a bound row (room: annex, note: ada.student). The runner reads the text in the language of the step. A cell that you do not name is not sent, and the row keeps its value. A cell must be a column of the columns: line of the sheet that a person can edit. A lifecycle state, a computed or aggregate column, a slug, an unguessable and a column that a set of the region fixes are values and not cells.
  • A page holds one sheet, so the table names it. A sheet and a form can be on one page: send one request for each submit. A sheet before a fill, or a fill before a sheet, without a submit between them is refused.
  • submit sends the save. submit delete and submit as <name> after a sheet are refused: the save redirects nowhere, so there is no row to bind. Bind a row with expect row … as <name>.

The runner does what the grid does. It reads the configuration of the grid from the page, reads the rows that the sheet lists in windows of 200, and sends the save with the stamp of each row. The stamp is a value that only the engine computes from the stored row. The engine reads the save through the same code as a save from a browser: the stamp check, the grants, the hooks, the limit on the rows of a save and the transaction. The runner does not run the JavaScript of the grid. A test of the keyboard, the paste or the undo of the grid belongs in the browser tests of the engine.

After a sheet, the answer is data and not a page. The outcome word reads it:

The engine answered Write
ok: true expect saved
ok: false with a message under a cell expect invalid <row>.<column>
ok: false with a sentence and no cell expect rejected ["<text>"]
303 to the login page, 403, 404, 410, 503 expect login, refused, missing, gone, unavailable

expect invalid names the cells as <row>.<column>, each once, and <row> is the name that the sheet gave the row. A quoted text after a name holds when the text is part of a message of that cell. The comparison ignores the difference between one space and several, and keeps the case.

sheet assignments {
row sam_welcome { status: "confirmed" }
row alex_welcome { status: "confirmed" }
}
submit
expect invalid alex_welcome.status "all the volunteers it needs"

The welcome desk needs two volunteers and has one. Either row alone fits, and both together do not. The engine marks the cell of the second row. A rule of the table that has no cell to stand under, or that does not name one with at, is a sentence of the save, and the sentence names the row:

expect rejected "Coffee beans: A donation needs a note."

A save is one transaction. Every answer other than saved means that nothing was written. Show it with expect row:

expect row assignments where id = sam_welcome.id { status: waitlist }
expect row assignments where id = alex_welcome.id { status: cancelled }

After a sheet and its submit, the page is finished, also after invalid. Open the page again to send a corrected save. expect shows has no page to read: the engine answered with data.

A control of a form takes the stored UTC time. A cell of a sheet holds what the grid draws: the time on the wall clock of the time zone of the page, in the notation of the language of the grid, without seconds. In New York, 2026-07-01T16:30:00Z is 2026-07-01 12:30 on an English grid and 01.07.2026 12:30 on a German grid. When you write a bound datetime as a cell, the runner writes it this way:

sheet items {
row zero { starts_at: src.starts_at }
}
submit
expect saved
  • The runner takes the zone from the configuration of the grid on the page, and the text from the function of the engine that draws a cell. It then reads the text back with the code that reads a cell in a save.
  • Some times have no such text. 2026-07-01T16:30:45Z has seconds, and the cell holds minutes only. 2026-11-01T06:30:00Z is 01:30 on the night that the clocks in New York go back, and that clock time is two moments. A cell has no offset to tell them apart. For these times the step fails before it sends a request, and the message says why. The runner does not choose a moment.
  • A fill of a form is not affected. Its control takes the stored time with the seconds and the offset.
  • A sheet … anyway for a grid that the page did not draw has no zone to read. The cell keeps the stored UTC time, which names its own zone.

A sheet lists some rows of a table. The where: of the sheet, the row filter of the user and a gone state leave other rows out. The where: is also a condition of every statement of the save, so a save that names a row outside it must write nothing. The grid has no stamp for a row that it does not show, so a plain sheet that names such a row fails before the first request. Write anyway to send it:

expect hides "Paper"
sheet line_items anyway {
row paper { quantity: "999" }
row toner { quantity: "7" }
}
submit
expect rejected "no longer exists"
expect row line_items where id = paper.id { quantity: 2 }
expect row line_items where id = toner.id { quantity: 1 }

The sheet lists the items that are not paid. Paper is paid, so the engine finds no row for it and refuses the whole save. Toner is listed, and it is not changed either. The runner sends a row that the sheet lists with its real stamp, and a row that the sheet does not list with a stamp of no row. A note under the test names the rows that it sent in this way. The same word sends a row that another person deleted after the page was drawn.

The rules of the word:

  • anyway sends a row that the sheet does not list. It does not reach a sheet that the page did not draw: when the access: of the sheet leaves the user out, the page has no grid, and the engine answers a save sent there with 400. Write sheet <table> anyway { … } to send the save that the grid would have sent, with the page’s token and language and a stamp of no row, and expect 400 for the answer. The runner has no columns to check for a grid that the page did not draw; the check before the first request holds each cell to a column of the sheet. A note under the test records it.
  • A cell that is a sensitive column that the role is not granted is not in the grid. The step fails and names the column.

submit sends the form that the last fill filled. With no fill before it, it sends the only form of the page, or the only form that the page draws to the user (see Choose the form of a fill). submit delete needs delete in the actions: of the form and an existing row. When the page draws two forms to the user, submit delete in region <test_id> names the form (see Choose the form of a delete). When the page draws no form of the region to the user, submit delete anyway sends the delete that the form would send (see Send a delete that the page did not draw). After submit save as <name>, the runner binds the row that the save redirected to. That works when the page that follows the save is the page of the saved row. A form with after_save: that leads elsewhere cannot bind with as; bind the row with expect row … as <name>.

An application can declare an app-wide scope, such as scope term ref(terms) "Term". The engine keeps the choice of each session, and every list and page that reads a scoped table reads the data of the chosen row. A test that does not choose always sees the default scope, so a page of an earlier term or another season cannot be reached without the selector. choose <scope> = <name> does what a person does with the selector in the page header: it picks a row and sends the choice. Bind the row first. The name is the whole row. An id, a text or a column of a row (last_term.id) is refused:

open courses
expect ok
choose term = last_term
expect saved
open courses
expect ok
expect rows in report of courses = 1
expect shows "7b M" in report of courses
expect hides "8b M" in report of courses

The step needs a page on screen: an open that ended in expect ok, because the selector is part of that page. The runner reads the form of the selector from the page that the engine drew. It sends the address, the token and the field of that form, and the id of the row. It does not write any of them itself. The engine answers with one of three words:

The engine answered Write
303 back to the page: the choice is stored expect saved
404: the row is not one that the user can choose. The selector offers every row of the scope table, so this is a row that was deleted after the test bound it expect missing
303 to the login page: a visitor is not signed in expect login

The step does not read the page that the 303 leads to. Open the page again and check what it shows. The step leaves no page on screen, as a save does.

The choice belongs to the session of the user. It stays for the later steps of that user in the same test. Another user and another test do not see it, and as anonymous starts without a session. An anonymous visitor is not shown the selector. A test of the visitor sends the request that the selector would send and says so in a note under the test. The same note appears for a row that the selector does not offer. A write is limited by the chosen scope too: a form that saves a row of another scope is answered with a message until the user chooses that scope.

sign out does what a person does with the sign-out button of the account menu. The session of the user who acts ends on the server, and the actor is anonymous afterwards. The next as <user> signs in again, with a new session.

A choice of a scope belongs to the session, so a new session starts at the default: of the scope. This test chooses the earlier term, signs out and signs in again:

sign out
as reuter
open courses
expect ok
expect rows in report of courses = 1
expect shows "8b M" in report of courses
expect hides "7b M" in report of courses

Before the sign out, the same test has chosen the earlier term, and open courses showed 7b M.

as <user> without a sign out goes back to the session that the user holds, in the state that the user left it. The choice is still there:

as kohl
as reuter
open courses
expect ok
expect shows "7b M" in report of courses
expect hides "8b M" in report of courses

The rules of the step:

  • The runner sends the form of the sign-out button: a POST to the sign-out address of the engine with the CSRF token of the session. The engine revokes the session row and the rows that depend on it, such as the choice of a scope, and answers with a 303 to the login page. A cookie that a test wiped in the client would leave the session in the file of the tenant. The step fails when the engine answers with anything else, and it shows the status.
  • The step has no outcome. The answer is always the redirect to the login page, and the runner holds it. An expect after sign out is refused, and the message says why.
  • The step needs a user who is signed in. The check before the first request refuses it when nobody acts and when the actor is anonymous, also after an earlier sign out.
  • The step needs no page on screen, and it leaves none. A fill, a submit and a page assertion after it need an open first. The page that a user opens after the sign-out is the page that a visitor gets: a page for signed-in users answers expect login.
  • Bound names stay valid. They are rows, and a sign-out does not change a row.
  • Other users keep their sessions.

run transition <name> presses the button of the transition on the open page. When the engine did not draw the button for this user (the user’s rule refuses it, or the row is in another state), the runner sends the request that the button would send and says so in a note under the test. The request passes through the same session, CSRF and authorization code. That is how a test shows that a transition is refused. A save does this only when you write fill … anyway.

The word depends on what the user lacks, and the page drew no button in both cases:

The user lacks The engine answers Write
The role of the transition’s access: rule 403 expect refused
The row: the user holds the role, but the where of the rule or the page’s row filter excludes this row 404 expect missing

The engine decides the role first and reads the row second. It answers 404 for a row that a filter excludes so that a 403 does not tell the user that the row exists.

Every open, submit, download, choose and run is followed by one outcome.

Write The engine answered
expect ok 200, the page
expect saved 303 to a page other than the login page: a save or a transition
expect deleted 303 after submit delete
expect invalid <field>[, <field>] 200, the form again, with exactly those controls marked invalid and a message for each. After a sheet, the cells as <row>.<column>
expect rejected ["<text>"] 200, the page again with the message of a rule that stopped the step, and no control marked invalid
expect refused 403: the user is known and a rule says no
expect missing 404: the row does not exist for this user, or the route is closed
expect gone 410, on a public page of a row in a gone state
expect login 303 to the login page
expect unavailable 503: the page cannot be served yet, for example a page of an app with a scope that has no scope row. Only a 503 has this word
expect <status> Exactly that HTTP status, for an answer that no word above names: a 4xx other than 403, 404 and 410

The runner reads the first response. It follows no redirect except the language redirect of an open, a download and the window of a sheet (below). Each step can end in some of these words only: open in ok, refused, missing, gone, login and unavailable; submit in saved, invalid, rejected, refused, missing, gone, login and unavailable (also for the save of a sheet); submit delete in deleted, rejected, refused, missing, gone, login and unavailable; download in ok and missing; run in saved, rejected, refused, missing, gone, login and unavailable; choose in saved, missing and login. A run is never ok: a move that happened is a 303, and a 200 always carries the sentence of a rule that stopped it. The check runs before the first request.

An application that lists several locales: has one address for each language of a public page. The first visit to the address in the application’s own language, with another language in the request, is answered with a 302 to the same page under the language’s prefix, such as /de/. The locale: of the suite is the Accept-Language of every request, so an open of a public page in a suite with locale: de gets that 302.

as anonymous
open start
expect ok
expect shows "Events des Königreichs"
expect shows "Events auf Ihrem Gerät"

The runner follows that redirect once, as a browser does. The word is the answer of the prefixed page, and expect shows reads the German page. A note under the test says followed the language redirect to /de/….

  • The runner recognises the redirect by what the engine does: a 302 whose Vary names Accept-Language and whose Location is the address of the request under a language prefix. A 303 to the login page, any other 302, and a 301 are reported as they are. The page that the redirect leads to is not redirected again.
  • An open in the language of the application is not redirected. A page that is not public has one address in every language, so a German member who opens it is not redirected either.
  • A signed-in user whose language is not the language of the application is redirected from a public page, as a browser is.
  • A save from the German page goes to the prefixed address, and submit … as <name> binds the row that the save redirected to, with the prefix read off by the engine’s own code.
  • A click on a link of the site is not a first visit, and the runner follows no redirect for it. Write open <page> from <page>. See Click a link.
  • download and the window of rows that a sheet step reads its stamps from follow the same redirect once and write the same note. The engine does not redirect a file, because the address of a file is not a public page. The window is a page address. A page that a click opened is drawn without a prefix, so its window is an unprefixed address and the engine redirects the request of the runner.

An app can have a scope, for example the term of the school (scope term ref(terms)). A page that reads a table of that scope cannot be built before the first term exists. The engine then answers 503. A user who is signed in sees the engine’s own page: one sentence that says what is missing, and a button to the page that creates the first row. expect unavailable holds for this answer.

as head
open courses
expect unavailable
expect shows "This app needs the first Term before this page can show anything."
expect shows "Create the first Term"

The answer is a page, so expect shows and expect hides read its text. The text tells you which 503 you met. The test School first run in school/tests/first-run.mtdtest has no term in its seed. It also shows that the same page is ok after the first term is saved:

open courses
expect ok
expect shows "No courses are assigned to you in this term." in report of courses
  • The word means a 503 and nothing else. Every other 5xx has no word, and expect 500 is refused. expect 503 is refused too, and the repair says expect unavailable. Other causes of a 503 exist, for example a password check that could not start because the server was busy. They have the same word, and the text of the page tells them apart.
  • The word is valid after open, submit, submit delete, run and the save of a sheet. It is not valid after download and choose.
  • The page of a 503 is the page of the engine, and it has no region of your page. Read its text without in. in <region>, expect rows and in order are refused after it.
  • The page is finished, as it is after refused. A form step needs an open first. After a submit, submit delete or run that ended in unavailable, no page is left to read.
  • When a step that expects another word meets a 503, the failure prints both words, the status, the warning of the engine (reason=no_scope), the text of the page, and the word to write.
  • A page that is not public answers a visitor with login before it checks the scope. A user without the right for the page gets refused.

The engine answers some requests with a status that no word of the table names: 400 for a request that is not one of its forms, 408, 413 and 429. Write the number to say that the engine gave that answer.

submit
expect 400
expect none time_entries where description = "Forged booking"
  • The number is from 400 to 499, and it is not 403, 404 or 410. Those three have a word, refused, missing and gone. The check runs before the first request. For any other number the repair names the word to write: 200 is ok, invalid or rejected, 303 is saved, deleted or login, 503 is unavailable. Any other 5xx is refused, because a test that expects a server error passes while the defect stays. A number below 100 or above 599 is not a status.
  • The number takes the place of the word: a step has one expect that says how it ended. It may follow open, submit, download and run.
  • Like refused, a status finishes the page. Nothing is on screen afterwards, so fill, submit, expect shows, expect hides and expect rows need an open first, and submit … as <name> cannot bind a row.
  • When the status is not the one you wrote, the failure prints the position, both statuses, the word that the response has when it has one, the page’s message, and the warnings that the engine logged (server:), which say why it answered 400.
  • A response that fits no word and has no status after it still fails its step. The failure names the status to write.
  • A save sent to a form region that the access: of the region withholds from the user is answered 400, as is a region number that does not exist. The test learns what a visitor could learn by sending a wrong number, and nothing about which regions exist.

A rule of the table or of the page can stop a step and have no control to blame. The engine then answers 200, draws the page again with the sentence of the rule and marks no control invalid. expect rejected is the word for that answer. It covers:

  • a table check without at, and a unique(…) over several columns, that refuses a save. A check with at <field> and a require mark a control, so their answer is invalid;
  • a before hook that refuses a save or a delete;
  • a deny when that stops a save or a transition;
  • a require or a hook that stops a transition, and a transition whose row is no longer in a source state (“The status is now … Reload the page.”).
submit
expect rejected "end must be after the start"
expect none bookings where title = "Backwards"

The quoted text is optional. With a text, the text must be part of a message that the page shows. The comparison ignores the difference between one space and several, reads &amp; as &, and keeps the case. The messages are in the language of the step, so a German suite writes the German sentence. Without a text, any message passes, but the response must carry one. An empty text "" is refused, because it would match every message. When the text is not in the message, the failure prints the messages that the page showed.

A transition that moves the row answers with a redirect, so saved is the answer of a move that happened, and rejected is the answer of a move that a rule stopped. expect ok after a run is refused before the first request, and the repair names saved and rejected.

open ticket(radio)
expect ok
run transition start_repair
expect rejected "Add a diagnosis"
expect row tickets where id = radio.id { status: diagnosed }

invalid and rejected are never both true of one response. When the engine marks a control, the answer is invalid, and you name the controls. The word rejected does not name controls, and expect invalid does not take a text. Also assert with expect row, expect none or expect count that nothing was stored.

The runner finds the message in the two places where the engine draws it: the message at the top of the form that the step sent (a refused save and a refused delete), and the warning note beside the buttons of the lifecycle (a stopped transition). A note that you wrote with note is not read as a refusal. A response that shows a list of fields without marking a control is reported as it is and fits no word.

Three shapes read the committed rows, and there are no others.

expect row <table> where <condition> [{ <column>: <value> … }] [as <name>]
expect none <table> [where <condition>]
expect count <table> [where <condition>] = <n>

The runner opens a second, read-only connection to the tenant file. The assertion therefore sees every row, also a row in a gone state, a row of another season and a row that the signed-in user may not read. No right, row filter or scope applies.

expect row posts where title = "Club news" {
slug: "club-news"
status: draft
author: 1
published_at: empty
words: 4
} as article

expect row needs exactly one matching row. It fails with the number of rows and up to five ids when the condition matches none or several. expect none needs no row, and expect count needs the number after the last = of the line. Write the table by its name in schema.mtd; the physical name never appears.

The condition is the expression language of .mtd, with unqualified names that are columns of the table.

  • A path walks references: post.priority = 3.
  • An enum value or a state is a bare word: status = published.
  • exists(...), aggregates and computed columns work: assigned >= needed, paid_total = 6000.
  • now is the clock: of the suite. today is that day in the time zone of the application.
  • :user, :route and dev() are refused: a test asserts what was stored, whoever asked.
  • Money in a condition is whole cents. The block of the same assertion writes whole units.
expect count shifts where title = "Past cleanup" and assigned = 2 = 1

The block lists stored columns by their logical names (author, not author_id). Each column appears at most once. The runner compares the stored value with the value you wrote. A failure lists every column that differs, with both values.

Column Write Example
text, long_text, markdown, email, slug quoted text title: "Club news"
bool true or false published: true
int a whole number needed: 4
money an amount with its point, in whole units amount: 14.50
decimal(n) a number with at most n places rating: 4.5
date a date paid_on: 2026-09-30
datetime UTC, with seconds and Z starts_at: 2026-10-05T07:00:00Z
enum, a lifecycle state the value status: published
ref the id of the row author: 1
a column of a bound row the name and a column, or the bare name for a ref post: article.id
any stored column empty approved_by: empty

The facts about a stored file are columns of the row, for example attachment_filename: "report.pdf" and attachment_bytes: 580 (see Assert the facts about a stored file). These columns cannot be asserted: created_by and updated_by, an unguessable (read it from a binding), the address of the bytes of an img or a file, a multi and any computed column. Compare a computed column in the condition instead. A money amount needs its decimal point: 12 is refused and the message asks for 12.00. More places than the column keeps is refused, never rounded.

submit … as <name> and expect row … as <name> bind a name to a row. The name is usable in the steps after it, as the row looked when it was bound. It exposes the stored columns: article.id, article.slug, article.preview_token. Write it without a colon in an open argument, in a where, and as a value of a fill control or of a column in a block. See Use a bound row as a value.

expect row posts where id = typo.id { status: draft }

A name is bound once in a test and is not the name of a user. Deleting the row does not unbind the name, so a test can delete a row and then open its address to see the 404. A name that is also a column of the asserted table is refused.

A bound name stands for a value in two places: a control of a fill, and a column of an expect row block. Write the name, or the name and a column, as you write it in open.

Write Meaning
lena.id The column id of the row that lena bound.
lena The id of that row, for a field or column that is a ref to the table of the row.
door.title Any stored column of the row, as it was when the row was bound.

In a fill, the runner sends the column as a person would type it, so the save stores the same reference:

open assignment.new
expect ok
fill assignments {
volunteer: lena.id
shift: welcome.id
status: "confirmed"
}

The row lena was bound by expect row volunteers … as lena, and welcome by an expect row shifts … on the shift’s title. The test does not need to know that the new volunteer has the id 4, and it does not break when the seed grows.

In a block, the runner compares the stored column with the column of the bound row:

expect row comments where body = "Good news." {
post: square
guest_name: "Rita"

post is a ref to posts, and square is a bound row of posts, so post: square means the id of that row. When the values differ, the failure shows the expected value and then the name as you wrote it: expected 2 (square).

The check before the first request holds the value to the column that it is written for:

The field or column is The bound column must be
ref to a table, and a multi in a fill the id of a row of that table (the bare name, or .id), or a ref to that table
int an int, or an id
text, long_text, markdown, email, slug one of these five
bool, date, datetime, money the same type
decimal(n) a decimal(n) with the same n
enum an enum with the same values in the same order

A mismatch is refused where you wrote it. The repair lists the columns of the bound row that fit. The bare name is the id only for a ref. In a block, a bare name on an enum column is a value of the enum. A name that is not bound yet, a column that is not stored, and a path through a reference such as article.author.name are refused.

A bound row is a snapshot, so a column of a row that was deleted or changed later still has the value from the time of the binding. The name of the row that the same step binds with as is not usable in that step’s own block.

A fill sends the column as a person would type it:

The column is The runner sends
int, ref, an id the digits
text and the other text types, enum the text, or the name of the value
date the date as 2026-10-05. Every locale reads it.
datetime the stored UTC time, such as 2026-07-01T16:30:00Z. The engine reads it as that moment in every time zone. A cell of a sheet is the exception. See Fill a cell with a time.
bool the state of the checkbox
money, decimal(n) the number as the form of the page draws it, in the notation of the language of the page
an empty column an empty text

A number has every decimal place, no thousands separator, and the decimal separator of the language of the page. An amount of 63 euros and 44 cents is 63.44 on an English page and 63,44 on a German page. A negative number has a minus sign. The runner asks the engine for this text. The engine uses the same function that fills the control of a form with a saved number. So the control has the text that a person would send again, and the save stores the same number.

open payment.new
expect ok
fill payments {
due: open_due.id
amount: first_payment.amount
method: "cash"
}

The language of the page is the language of the form that the runner fills. When a page has no form (fill … anyway), it is the locale: of the user, or of the suite. In a suite with locale: de, a test can pass a number on without writing the comma:

open mark(bens_mark)
expect ok
fill marks {
raw_points: annas_now.raw_points
}

A column of another kind, or of another number of decimal places, does not fit a money or a decimal(n) control. A file or img control takes a file and not a bound column.

The assertions of the previous section read the rows past every filter. They cannot say what a user saw. Three more assertions read the page that the engine drew for the user. They do not read the database, and they add no rule of their own. The HTML of the engine is the one answer to the question “what does this user see?”.

expect shows "<text>" [in <region>]
expect hides "<text>" [in <region>]
expect rows in <region> = <n>
expect rows in <region> in order "<a>", "<b>" …

A <region> is written <kind> of <table> or region <test_id>. See Name a region.

Write It holds when
expect shows "<text>" The text is in the content of the page.
expect hides "<text>" The text is not in the content of the page.
expect shows "<text>" in <region> The text is in that region.
expect hides "<text>" in <region> The text is not in that region.
expect rows in <region> = <n> The region drew <n> data rows.
expect rows in <region> in order "<a>", "<b>" … The region shows the texts in this order.

An assertion reads the page that the last step drew. These steps leave a page:

  • an open that ended in expect ok;
  • a submit or a run that the engine answered by drawing the page again: expect invalid and expect rejected;
  • an open that ended in expect unavailable. The page is the page of the engine and has no region, so only the text of the whole page can be read.

After saved, deleted, refused, missing, gone or login, no page is left. The check before the first request refuses an assertion that has no page, and the repair says to open the page. The next as, open, submit or run replaces the page.

shows and hides read the text in the <main> element of the page. The header, with the navigation and the account menu, and the footer are not part of it. The runner reads the text as a person reads it:

  • It resolves character references. &amp; is &.
  • It puts a space between blocks, for example between two cells of a table.
  • It counts one space or many spaces as one space.
  • It keeps the case. public note is not Public note.
  • It skips scripts, styles, icons that are marked aria-hidden, elements with hidden, and the values of controls.
  • It reads the text that only a screen reader announces, such as the caption of a table.

The text is a part of the page text. hides "Ben" fails when the page shows Benjamin. Write a text that is specific to the row. An empty text is refused. A page with no text in <main> fails every text assertion, so hides cannot hold for an empty page.

Write a region in one of two ways:

  • <kind> of <table>: the kind, the word of, and the table, as the page declares the region. A region of the form list of :child.absences is list of absences. This works for a region that has a label and is the only region of its kind and table on the page.
  • region <test_id>: the test_id: that the page source gives to the region. This works for every region of every kind, with a label or without, and for two regions of one kind and table.
expect shows "Completed" in report of marks
expect rows in list of enrolments = 2
expect rows in region availability_list = 1

A test_id is one name of lower-case letters, digits and _, at most 40 characters, and unique on its page. The engine writes it into the page as data-testid. See Regions: test_id. region is never a region kind, so the first word tells the two ways apart.

The check before the first request refuses these cases, each with a repair:

  • The page on the screen has no region of that kind and table, or no region with that test_id. The repair lists the regions of the page, or its test ids, and says when the id is on another page.
  • The page has two regions of that kind and table. The runner cannot tell them apart. Give each region a test_id: and write in region <test_id>.
  • The region has no label. The engine marks a region by the id of its heading, and a region without a label has none. Give the region a test_id: and write in region <test_id>.
  • expect rows names a region that is not a list or a report.

If the engine did not draw the region for this user, for example because the access: of the region leaves the user out, the step fails. It fails also for expect hides. A text cannot be hidden from a region that was not there. The failure lists the regions that the page drew, with the heading of each and its test_id.

expect rows counts the data rows that the region drew. Use it for a list or a report. A grouped report draws one row for each group.

open subscribe(quiet)
expect ok
expect rows in list of events = 1
expect shows "Bear 1" in list of events
expect hides "Raid 1" in list of events

The number is the number of rows on the page, not the number of rows in the table. A report shows page_size: rows at most, 25 when you write none. A list shows limit: or page_size: rows at most. Use expect count to count the table. A region without rows draws its empty: text, and expect rows in … = 0 holds for it. A region that drew neither rows nor its empty: text drew a note instead of its rows, and every assertion about that region fails.

expect rows in <region> in order "<a>", "<b>" … holds when the region shows the texts in this order. Use it where the order is the point, for example a sort: of the region.

as anonymous
open start
expect ok
expect rows in region front_posts = 3
expect rows in region front_posts in order "Library opens", "Market day", "Budget decided"

The front page of the newspaper has sort: published_at desc. The test publishes three posts with three times, and the front page shows the newest first. The test The front page lists the newest post first is in city-news/tests/editorial.mtdtest.

  • The first text is searched from the start of the region. Each of the other texts is searched from the end of the text before it. The texts do not need to be next to each other, and other text can be between them.
  • A text that you write twice is found at its next place. "note", "note" needs two.
  • The runner reads the region as expect shows does: it resolves character references, counts white space as one space, and keeps the case. The text is a part of the text of the region, so use a part that is specific. "Draft" is also in "Draft note".
  • It reads the text of the region and not its rows. A text that spans two cells of a row, such as Ada | Passed, is not one text. Write one text for each cell.
  • A region of any kind can be read, and the region is written as for shows. A page of the engine after expect unavailable has no region.
  • The check before the first request refuses a list of fewer than two texts and an empty text.
  • The order is the order that the engine drew. The runner does not sort anything and does not read the database.

When a text is out of place, the failure says if the text is not in the region at all or only before the end of the text before it. It prints the order that the region shows, by the first place of each text, and then the rows of the listing. This is a real failure of the city-news example, with the sort: of the front page changed to published_at:

city-news/tests/editorial.mtdtest:152:5: expect rows in region front_posts in order "Library opens", "Market day", "Budget decided" (after open start at city-news/tests/editorial.mtdtest:149:5)
expected: in order "Library opens", "Market day", "Budget decided" in region front_posts
actual: "Market day" is not shown after "Library opens"
region front_posts shows "Market day" only before the end of "Library opens", so the order is not the one written
shown: order found: "Budget decided" < "Market day" < "Library opens"
shown: row 1: | 2026-09-12 08:00 | Budget decided | |
shown: row 2: | 2026-09-25 08:00 | Market day | |
shown: row 3: | 2026-09-30 12:00 | Library opens | |

The two kinds of assertion answer two questions. Use both in one test to show that a row is stored and that a user is not shown it:

as anonymous
open post(article)
expect missing
open start
expect ok
expect rows in region front_posts = 0
expect hides "Club news" in region front_posts
expect count posts where title = "Club news" = 1

A hides alone can hold for a wrong reason: if the page listed nothing at all, any text would be absent. Add a shows or a rows that must hold for the same page. The newspaper test does this after it publishes the post:

as anonymous
open post(article)
expect ok
open start
expect ok
expect rows in region front_posts = 1
expect shows "Club news" in region front_posts

A failed assertion prints what the page showed. For a text, it prints the first 600 characters of the text that the runner read. For hides, it prints the text around the match. For a listing, it prints up to ten rows, with the cells of each row separated by |, and the sentence of the pager.

This is a real failure of the school example. The test expected the report of marks to be empty before the release of the assessment, and a change of the report drew the mark:

school/tests/grades.mtdtest:113:5: expect rows in report of marks (after open mine at school/tests/grades.mtdtest:111:5)
expected: 0 rows in report of marks
actual: 1 row
shown: row 1: Class test 1 | 11 | Completed

They prove what the engine drew for this user in this state. A row filter, a scope, a grant, a gone state and a where: of a region are tested by the page that applies them.

They do not test the look of the page, the focus order or the accessibility. They do not read scripts or pictures. The text of a label is copy: when you reword a label, a shows of that label fails. Prefer a value from your data and a count of rows. The assertions do not read an export (CSV, calendar feed, workbook), the grid of a sheet or the drawing of a chart.

matterdata test <app-dir> [-run <regexp>] [-keep [-serve]]

The command reads tests/*.mtdtest in file name order, parses every file, compiles the application and validates every suite. It runs only when all of that succeeds. A file that does not parse or validate is printed on standard error with file:line:column and a repair line, nothing runs, and the exit status is 1.

A run prints a line for each test and, for a failed test, the position and text of the failing step. This is a real run of the expenses example with one outcome changed to the wrong word:

$ matterdata test expenses -run "A head cannot"
suite "Expense claims" (expenses/tests/claims.mtdtest)
FAIL A head cannot approve their own claim, and finance can (15 ms)
expenses/tests/claims.mtdtest:187:5: expect refused (after run transition approve at expenses/tests/claims.mtdtest:184:5)
expected: refused
actual: rejected
a rule stopped the step: the engine answered 200 with a message and marked no control invalid. If the refusal is what the test is about, write: expect rejected "<part of the message>"
status: 200
message: You cannot approve your own claim.
server: level=WARN msg="transition refused" table=claims transition=approve why="a deny when holds" rule="employee = :user.employee_id"
FAIL 1 test, 0 passed, 1 failed, 6 not selected in 64ms

For a failed expectation it prints the expected and actual outcome, the validation messages that the page showed, and the warnings that the engine logged for the request. For a row assertion it prints every column that differs, each with the position of the value you wrote. The exit status is 1 when a test fails or a suite cannot start, and 0 otherwise.

Flag Meaning
-run <regexp> Runs the tests whose <suite name>/<test name> matches the expression. The others are counted as not selected. A pattern that matches nothing is a failure.
-keep Keeps the directory of each failed test, with its SQLite file and files, and prints its path.
-serve With -keep: serves the first kept tenant at http://workflow.localhost:<port>/ in development mode until you press Ctrl-C. It prints the addresses of the declared users and their password.

The engine does not run these yet. Each is listed on Project status.

  • expect mail, run job, run button and run row_action are reserved words. The compiler refuses each with a message that says it is not built.
  • A fill of a page that draws two forms of one table to the same user needs in region <test_id>, and so does a submit delete. A sheet step has no in region, because a page holds one sheet.
  • An order is read in one region. No assertion compares the position of a text in one region with a text in another region, and no assertion reads a sort order from the stored values of a column.
  • A sheet cell cannot hold a time with seconds or a time in the hour that a clock goes back. The step fails for it, as described in Fill a cell with a time.
  • The dialog that creates a ref row is not driven. A file cannot be chosen or removed in a cell of a sheet, and download does not read the headers or the bytes that the engine sends.
  • No assertion reads the value of a control. After open <page>.new copying <name>, expect shows reads the text of a long text control, and no step reads the value of a one-line control. Show what a copy carried by saving it and asserting the stored row.
  • A delete on a form whose actions: does not list delete answers 400. No outcome word fits it, and expect 400 does. A delete that a delete { access: … } block withholds from the user answers 403: write expect refused, then expect row to show that the row stayed.

Website privacy policy