> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.doc-detective.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.doc-detective.com/_mcp/server.

# Variables and control flow, written as tests

> Procedures that load variables, pass values from one step to the next, add custom assertions, run steps conditionally, and route on a step's result, in every supported format.

Each example on this page shows one procedure as prose, detected tests, inline tests, and a standalone spec. For what each tab holds, see [Navigation and interaction](/reference/docs-as-tests/navigation-interaction).

## Call an API with a token from an environment file

This procedure uses [`loadVariables`](/docs/actions/loadvariables) and [`httpRequest`](/docs/actions/httprequest), with the step fields [`variables` and `assertions`](/reference/schemas/step), the [`jq()` function](/reference/expressions#function-operators), and [`publicVariables`](/reference/schemas/test) on the test and the [spec](/reference/schemas/specification).

The example folder holds the `api.env` file the steps load:

**`api.env`**

```text title="api.env"
API_URL=http://localhost:8092/api
API_TOKEN=docs-example-token
```

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create an account with an API token

Keep the API address and your token in an `+api.env+` file next to this page:

[source,text]
----
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
----

. Load the variables from your `+api.env+` file.
. Send a `+POST+` request to `+$API_URL/accounts+` with the header `+Authorization: Bearer $API_TOKEN+` and this body:
+
[source,json]
----
{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
----
+
The API returns status `+200+` and the new account, with `+plan+` set to `+team+`. Note the account's `+name+`, its `+seats+`, and its first role.
. Look up the account. Send a `+GET+` request to `+$API_URL/accounts?name=<name>&seats=<seats>&role=<role>+`. The response shows the same name, seat count, and role.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account with an API token</title></head>
<body>
<h1>Create an account with an API token</h1>
<p>Keep the API address and your token in an <code>api.env</code> file next to this page:</p>

<pre><code class="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</code></pre>

<ol>
  <li>Load the variables from your <code>api.env</code> file.</li>
  <li>Send a <code>POST</code> request to <code>$API_URL/accounts</code> with the header <code>Authorization: Bearer $API_TOKEN</code> and this body:
    <pre><code class="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</code></pre>
    <p>The API returns status <code>200</code> and the new account, with <code>plan</code> set to <code>team</code>. Note the account's <code>name</code>, its <code>seats</code>, and its first role.</p></li>
  <li>Look up the account. Send a <code>GET</code> request to <code>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</code>. The response shows the same name, seat count, and role.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create an account with an API token
===================================

Keep the API address and your token in an ``api.env`` file next to this page:

.. code-block:: text

   API_URL=http://localhost:8092/api
   API_TOKEN=your-api-token

#. Load the variables from your ``api.env`` file.

#. Send a ``POST`` request to ``$API_URL/accounts`` with the header ``Authorization: Bearer $API_TOKEN`` and this body:

   .. code-block:: json

      {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}

   The API returns status ``200`` and the new account, with ``plan`` set to ``team``. Note the account's ``name``, its ``seats``, and its first role.

#. Look up the account. Send a ``GET`` request to ``$API_URL/accounts?name=<name>&seats=<seats>&role=<role>``. The response shows the same name, seat count, and role.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-api-token">
  <title>Create an account with an API token</title>
  <taskbody>
    <context>
      <p>Keep the API address and your token in an <codeph>api.env</codeph> file next to this page:</p>
      <codeblock outputclass="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</codeblock>
    </context>
    <steps>
      <step><cmd>Load the variables from your <codeph>api.env</codeph> file.</cmd></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>$API_URL/accounts</codeph> with the header <codeph>Authorization: Bearer $API_TOKEN</codeph> and this body:</cmd>
        <info><codeblock outputclass="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</codeblock>
          <p>The API returns status <codeph>200</codeph> and the new account, with <codeph>plan</codeph> set to <codeph>team</codeph>. Note the account's <codeph>name</codeph>, its <codeph>seats</codeph>, and its first role.</p></info></step>
      <step><cmd>Look up the account. Send a <codeph>GET</codeph> request to <codeph>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</codeph>. The response shows the same name, seat count, and role.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true} -->

# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
   <!-- step {"loadVariables":"api.env"} -->
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
   <!-- step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} -->
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
   <!-- step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true} */}

# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
   {/* step {"loadVariables":"api.env"} */}
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
   {/* step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} */}
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
   {/* step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create an account with an API token

// (test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true})

Keep the API address and your token in an `+api.env+` file next to this page:

[source,text]
----
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
----

. Load the variables from your `+api.env+` file.
+
// (step {"loadVariables":"api.env"})
. Send a `+POST+` request to `+$API_URL/accounts+` with the header `+Authorization: Bearer $API_TOKEN+` and this body:
+
[source,json]
----
{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
----
+
The API returns status `+200+` and the new account, with `+plan+` set to `+team+`. Note the account's `+name+`, its `+seats+`, and its first role.
+
// (step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}})
. Look up the account. Send a `+GET+` request to `+$API_URL/accounts?name=<name>&seats=<seats>&role=<role>+`. The response shows the same name, seat count, and role.
+
// (step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account with an API token</title></head>
<body>
<!-- test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true} -->
<h1>Create an account with an API token</h1>
<p>Keep the API address and your token in an <code>api.env</code> file next to this page:</p>

<pre><code class="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</code></pre>

<ol>
  <li>Load the variables from your <code>api.env</code> file.
    <!-- step {"loadVariables":"api.env"} --></li>
  <li>Send a <code>POST</code> request to <code>$API_URL/accounts</code> with the header <code>Authorization: Bearer $API_TOKEN</code> and this body:
    <pre><code class="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</code></pre>
    <p>The API returns status <code>200</code> and the new account, with <code>plan</code> set to <code>team</code>. Note the account's <code>name</code>, its <code>seats</code>, and its first role.</p>
    <!-- step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} --></li>
  <li>Look up the account. Send a <code>GET</code> request to <code>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</code>. The response shows the same name, seat count, and role.
    <!-- step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create an account with an API token
===================================

.. test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true}

Keep the API address and your token in an ``api.env`` file next to this page:

.. code-block:: text

   API_URL=http://localhost:8092/api
   API_TOKEN=your-api-token

#. Load the variables from your ``api.env`` file.

   .. step {"loadVariables":"api.env"}

#. Send a ``POST`` request to ``$API_URL/accounts`` with the header ``Authorization: Bearer $API_TOKEN`` and this body:

   .. code-block:: json

      {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}

   The API returns status ``200`` and the new account, with ``plan`` set to ``team``. Note the account's ``name``, its ``seats``, and its first role.

   .. step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}}

#. Look up the account. Send a ``GET`` request to ``$API_URL/accounts?name=<name>&seats=<seats>&role=<role>``. The response shows the same name, seat count, and role.

   .. step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-api-token">
  <title>Create an account with an API token</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":true}'/>
    <context>
      <p>Keep the API address and your token in an <codeph>api.env</codeph> file next to this page:</p>
      <codeblock outputclass="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</codeblock>
    </context>
    <steps>
      <step><cmd>Load the variables from your <codeph>api.env</codeph> file.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"api.env"}'/></info></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>$API_URL/accounts</codeph> with the header <codeph>Authorization: Bearer $API_TOKEN</codeph> and this body:</cmd>
        <info><codeblock outputclass="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</codeblock>
          <p>The API returns status <codeph>200</codeph> and the new account, with <codeph>plan</codeph> set to <codeph>team</codeph>. Note the account's <codeph>name</codeph>, its <codeph>seats</codeph>, and its first role.</p>
          <data name="doc-detective" value='step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}}'/></info></step>
      <step><cmd>Look up the account. Send a <codeph>GET</codeph> request to <codeph>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</codeph>. The response shows the same name, seat count, and role.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&amp;seats=$ACCOUNT_SEATS&amp;role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false} -->

# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
   <!-- step {"loadVariables":"api.env"} -->
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
   <!-- step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} -->
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
   <!-- step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false} */}

# Create an account with an API token

Keep the API address and your token in an `api.env` file next to this page:

```text
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
```

1. Load the variables from your `api.env` file.
   {/* step {"loadVariables":"api.env"} */}
2. Send a `POST` request to `$API_URL/accounts` with the header `Authorization: Bearer $API_TOKEN` and this body:

   ```json
   {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
   ```

   The API returns status `200` and the new account, with `plan` set to `team`. Note the account's `name`, its `seats`, and its first role.
   {/* step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} */}
3. Look up the account. Send a `GET` request to `$API_URL/accounts?name=<name>&seats=<seats>&role=<role>`. The response shows the same name, seat count, and role.
   {/* step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create an account with an API token

// (test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false})

Keep the API address and your token in an `+api.env+` file next to this page:

[source,text]
----
API_URL=http://localhost:8092/api
API_TOKEN=your-api-token
----

. Load the variables from your `+api.env+` file.
+
// (step {"loadVariables":"api.env"})
. Send a `+POST+` request to `+$API_URL/accounts+` with the header `+Authorization: Bearer $API_TOKEN+` and this body:
+
[source,json]
----
{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}
----
+
The API returns status `+200+` and the new account, with `+plan+` set to `+team+`. Note the account's `+name+`, its `+seats+`, and its first role.
+
// (step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}})
. Look up the account. Send a `+GET+` request to `+$API_URL/accounts?name=<name>&seats=<seats>&role=<role>+`. The response shows the same name, seat count, and role.
+
// (step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account with an API token</title></head>
<body>
<!-- test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false} -->
<h1>Create an account with an API token</h1>
<p>Keep the API address and your token in an <code>api.env</code> file next to this page:</p>

<pre><code class="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</code></pre>

<ol>
  <li>Load the variables from your <code>api.env</code> file.
    <!-- step {"loadVariables":"api.env"} --></li>
  <li>Send a <code>POST</code> request to <code>$API_URL/accounts</code> with the header <code>Authorization: Bearer $API_TOKEN</code> and this body:
    <pre><code class="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</code></pre>
    <p>The API returns status <code>200</code> and the new account, with <code>plan</code> set to <code>team</code>. Note the account's <code>name</code>, its <code>seats</code>, and its first role.</p>
    <!-- step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}} --></li>
  <li>Look up the account. Send a <code>GET</code> request to <code>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</code>. The response shows the same name, seat count, and role.
    <!-- step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create an account with an API token
===================================

.. test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false}

Keep the API address and your token in an ``api.env`` file next to this page:

.. code-block:: text

   API_URL=http://localhost:8092/api
   API_TOKEN=your-api-token

#. Load the variables from your ``api.env`` file.

   .. step {"loadVariables":"api.env"}

#. Send a ``POST`` request to ``$API_URL/accounts`` with the header ``Authorization: Bearer $API_TOKEN`` and this body:

   .. code-block:: json

      {"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}

   The API returns status ``200`` and the new account, with ``plan`` set to ``team``. Note the account's ``name``, its ``seats``, and its first role.

   .. step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}}

#. Look up the account. Send a ``GET`` request to ``$API_URL/accounts?name=<name>&seats=<seats>&role=<role>``. The response shows the same name, seat count, and role.

   .. step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-api-token">
  <title>Create an account with an API token</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-api-token","if":"$$platform oneOf [linux, mac, windows]","publicVariables":["ACCOUNT_*"],"detectSteps":false}'/>
    <context>
      <p>Keep the API address and your token in an <codeph>api.env</codeph> file next to this page:</p>
      <codeblock outputclass="language-text">API_URL=http://localhost:8092/api
API_TOKEN=your-api-token</codeblock>
    </context>
    <steps>
      <step><cmd>Load the variables from your <codeph>api.env</codeph> file.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"api.env"}'/></info></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>$API_URL/accounts</codeph> with the header <codeph>Authorization: Bearer $API_TOKEN</codeph> and this body:</cmd>
        <info><codeblock outputclass="language-json">{"name": "Wren", "plan": "team", "seats": 5, "roles": ["admin", "billing"]}</codeblock>
          <p>The API returns status <codeph>200</codeph> and the new account, with <codeph>plan</codeph> set to <codeph>team</codeph>. Note the account's <codeph>name</codeph>, its <codeph>seats</codeph>, and its first role.</p>
          <data name="doc-detective" value='step {"httpRequest":{"url":"$API_URL/accounts","method":"post","request":{"headers":{"Authorization":"Bearer $API_TOKEN"},"body":{"name":"Wren","plan":"team","seats":5,"roles":["admin","billing"]}},"response":{"body":{"name":"Wren"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""],"variables":{"ACCOUNT_NAME":"$$response.body.name","ACCOUNT_SEATS":"jq($$response.body, \".seats\")","ACCOUNT_ROLE":"$$response.body.roles[0]"}}'/></info></step>
      <step><cmd>Look up the account. Send a <codeph>GET</codeph> request to <codeph>$API_URL/accounts?name=&lt;name&gt;&amp;seats=&lt;seats&gt;&amp;role=&lt;role&gt;</codeph>. The response shows the same name, seat count, and role.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$API_URL/accounts?name=$ACCOUNT_NAME&amp;seats=$ACCOUNT_SEATS&amp;role=$ACCOUNT_ROLE","method":"get","response":{"body":{"name":"Wren","seats":"5","role":"admin"}}},"assertions":"$$outputs.response.body.seats == $ACCOUNT_SEATS"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "publicVariables": [
    "API_URL"
  ],
  "tests": [
    {
      "testId": "data-api-token",
      "if": "$$platform oneOf [linux, mac, windows]",
      "publicVariables": [
        "ACCOUNT_*"
      ],
      "steps": [
        {
          "loadVariables": "api.env"
        },
        {
          "httpRequest": {
            "url": "$API_URL/accounts",
            "method": "post",
            "request": {
              "headers": {
                "Authorization": "Bearer $API_TOKEN"
              },
              "body": {
                "name": "Wren",
                "plan": "team",
                "seats": 5,
                "roles": [
                  "admin",
                  "billing"
                ]
              }
            },
            "response": {
              "body": {
                "name": "Wren"
              }
            }
          },
          "assertions": [
            "$$outputs.response.statusCode == 200",
            "$$outputs.response.body.plan == \"team\""
          ],
          "variables": {
            "ACCOUNT_NAME": "$$response.body.name",
            "ACCOUNT_SEATS": "jq($$response.body, \".seats\")",
            "ACCOUNT_ROLE": "$$response.body.roles[0]"
          }
        },
        {
          "httpRequest": {
            "url": "$API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE",
            "method": "get",
            "response": {
              "body": {
                "name": "Wren",
                "seats": "5",
                "role": "admin"
              }
            }
          },
          "assertions": "$$outputs.response.body.seats == $ACCOUNT_SEATS"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
publicVariables:
  - API_URL
tests:
  - testId: data-api-token
    if: $$platform oneOf [linux, mac, windows]
    publicVariables:
      - ACCOUNT_*
    steps:
      - loadVariables: api.env
      - httpRequest:
          url: $API_URL/accounts
          method: post
          request:
            headers:
              Authorization: Bearer $API_TOKEN
            body:
              name: Wren
              plan: team
              seats: 5
              roles:
                - admin
                - billing
          response:
            body:
              name: Wren
        assertions:
          - $$outputs.response.statusCode == 200
          - $$outputs.response.body.plan == "team"
        variables:
          ACCOUNT_NAME: $$response.body.name
          ACCOUNT_SEATS: jq($$response.body, ".seats")
          ACCOUNT_ROLE: $$response.body.roles[0]
      - httpRequest:
          url: $API_URL/accounts?name=$ACCOUNT_NAME&seats=$ACCOUNT_SEATS&role=$ACCOUNT_ROLE
          method: get
          response:
            body:
              name: Wren
              seats: "5"
              role: admin
        assertions: $$outputs.response.body.seats == $ACCOUNT_SEATS
```

### How the values flow

* `$API_URL` and `$API_TOKEN` come from the `api.env` file. Doc Detective substitutes them into the URL and the `Authorization` header.
* The first request's `variables` field sets `ACCOUNT_NAME` from `$$response.body.name`, and `ACCOUNT_SEATS` from `jq($$response.body, ".seats")`. It sets `ACCOUNT_ROLE` from `$$response.body.roles[0]`, the first item of the `roles` array. The second request uses all three in its URL, and its assertion reads `$ACCOUNT_SEATS` too.
* `assertions` adds custom checks to a step. Each check is an [expression](/reference/expressions) over the step's `$$outputs`, given as one string or as an array whose checks must all pass.
* Doc Detective masks every value it loads or substitutes as `***NAME***` in logs and reports. `publicVariables` lists the names to show: `ACCOUNT_*` on the test, and `API_URL` on the spec. A name listed in the config, any spec, or any test is public for the whole run. See [Keep secrets out of logs](/docs/ci/secrets).

### What detection finds

The prose has no links, bold text, or HTTP code blocks, so detection finds no steps. All three steps come from `step` statements.

The detected run also loads the `api.env` file before any test starts. The example's own `doc-detective.json` sets the config-level [`loadVariables`](/reference/schemas/config) field, and lists `API_URL` in the config-level `publicVariables`:

**`doc-detective.json`**

```json title="doc-detective.json"
{
  "detectSteps": true,
  "loadVariables": "api.env",
  "publicVariables": ["API_URL"]
}
```

A config-level file only fills variables that aren't already set, while a `loadVariables` step replaces them.

## Check your Node.js version

This procedure uses [`runShell`](/docs/actions/runshell), the step and test [`if`](/reference/schemas/test) conditions, the [`extract()` function](/reference/expressions#function-operators), and the [`onSkip` and `onFail` step routing](/reference/schemas/step-routing) entries `continue` and `stop`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check your Node.js version

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
The output starts with `+v+` and the major version, such as `+v22.11.0+`. You need version 18 or later.
. If Node.js printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
. Find the Node.js executable. On Windows, run:
+
[source,shell]
----
where node
----
+
On macOS and Linux, run:
+
[source,shell]
----
command -v node
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js version</title></head>
<body>
<h1>Check your Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <p>The output starts with <code>v</code> and the major version, such as <code>v22.11.0</code>. You need version 18 or later.</p></li>
  <li>If Node.js printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre></li>
  <li>Find the Node.js executable. On Windows, run:
    <pre><code class="language-shell">where node</code></pre>
    <p>On macOS and Linux, run:</p>
    <pre><code class="language-shell">command -v node</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check your Node.js version
==========================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   The output starts with ``v`` and the major version, such as ``v22.11.0``. You need version 18 or later.

#. If Node.js printed a version, print the npm version:

   .. code-block:: shell

      npm --version

#. Find the Node.js executable. On Windows, run:

   .. code-block:: shell

      where node

   On macOS and Linux, run:

   .. code-block:: shell

      command -v node
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-node-check">
  <title>Check your Node.js version</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <p>The output starts with <codeph>v</codeph> and the major version, such as <codeph>v22.11.0</codeph>. You need version 18 or later.</p></info></step>
      <step><cmd>If Node.js printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock></info></step>
      <step><cmd>Find the Node.js executable. On Windows, run:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock>
          <p>On macOS and Linux, run:</p>
          <codeblock outputclass="language-shell">command -v node</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true} -->

# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
   <!-- step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} -->
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} -->
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
   <!-- step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} -->
   <!-- step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true} */}

# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
   {/* step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} */}
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} */}
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
   {/* step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} */}
   {/* step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check your Node.js version

// (test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
The output starts with `+v+` and the major version, such as `+v22.11.0+`. You need version 18 or later.
+
// (step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}})
. If Node.js printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]})
. Find the Node.js executable. On Windows, run:
+
[source,shell]
----
where node
----
+
On macOS and Linux, run:
+
[source,shell]
----
command -v node
----
+
// (step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]})
+
// (step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js version</title></head>
<body>
<!-- test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true} -->
<h1>Check your Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <p>The output starts with <code>v</code> and the major version, such as <code>v22.11.0</code>. You need version 18 or later.</p>
    <!-- step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} --></li>
  <li>If Node.js printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} --></li>
  <li>Find the Node.js executable. On Windows, run:
    <pre><code class="language-shell">where node</code></pre>
    <p>On macOS and Linux, run:</p>
    <pre><code class="language-shell">command -v node</code></pre>
    <!-- step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} -->
    <!-- step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check your Node.js version
==========================

.. test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   The output starts with ``v`` and the major version, such as ``v22.11.0``. You need version 18 or later.

   .. step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}

#. If Node.js printed a version, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]}

#. Find the Node.js executable. On Windows, run:

   .. code-block:: shell

      where node

   On macOS and Linux, run:

   .. code-block:: shell

      command -v node

   .. step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]}

   .. step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-node-check">
  <title>Check your Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <p>The output starts with <codeph>v</codeph> and the major version, such as <codeph>v22.11.0</codeph>. You need version 18 or later.</p>
          <data name="doc-detective" value='step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}'/></info></step>
      <step><cmd>If Node.js printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR &gt;= 18"]}'/></info></step>
      <step><cmd>Find the Node.js executable. On Windows, run:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock>
          <p>On macOS and Linux, run:</p>
          <codeblock outputclass="language-shell">command -v node</codeblock>
          <data name="doc-detective" value='step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]}'/>
          <data name="doc-detective" value='step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false} -->

# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
   <!-- step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} -->
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} -->
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
   <!-- step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} -->
   <!-- step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false} */}

# Check your Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```

   The output starts with `v` and the major version, such as `v22.11.0`. You need version 18 or later.
   {/* step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} */}
2. If Node.js printed a version, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} */}
3. Find the Node.js executable. On Windows, run:

   ```shell
   where node
   ```

   On macOS and Linux, run:

   ```shell
   command -v node
   ```
   {/* step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} */}
   {/* step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check your Node.js version

// (test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
The output starts with `+v+` and the major version, such as `+v22.11.0+`. You need version 18 or later.
+
// (step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}})
. If Node.js printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]})
. Find the Node.js executable. On Windows, run:
+
[source,shell]
----
where node
----
+
On macOS and Linux, run:
+
[source,shell]
----
command -v node
----
+
// (step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]})
+
// (step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js version</title></head>
<body>
<!-- test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false} -->
<h1>Check your Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <p>The output starts with <code>v</code> and the major version, such as <code>v22.11.0</code>. You need version 18 or later.</p>
    <!-- step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} --></li>
  <li>If Node.js printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]} --></li>
  <li>Find the Node.js executable. On Windows, run:
    <pre><code class="language-shell">where node</code></pre>
    <p>On macOS and Linux, run:</p>
    <pre><code class="language-shell">command -v node</code></pre>
    <!-- step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]} -->
    <!-- step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check your Node.js version
==========================

.. test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   The output starts with ``v`` and the major version, such as ``v22.11.0``. You need version 18 or later.

   .. step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}

#. If Node.js printed a version, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR >= 18"]}

#. Find the Node.js executable. On Windows, run:

   .. code-block:: shell

      where node

   On macOS and Linux, run:

   .. code-block:: shell

      command -v node

   .. step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]}

   .. step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-node-check">
  <title>Check your Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-node-check","if":["$$platform oneOf [linux, mac, windows]"],"publicVariables":["NODE_MAJOR"],"detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <p>The output starts with <codeph>v</codeph> and the major version, such as <codeph>v22.11.0</codeph>. You need version 18 or later.</p>
          <data name="doc-detective" value='step {"stepId":"node-version","runShell":"node --version","assertions":"$$outputs.stdio.stdout matches /^v[0-9]+\\./","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}'/></info></step>
      <step><cmd>If Node.js printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":["$$steps.node-version.outputs.exitCode == 0","$$steps.node-version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version","assertions":["$$outputs.exitCode == 0","$NODE_MAJOR &gt;= 18"]}'/></info></step>
      <step><cmd>Find the Node.js executable. On Windows, run:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock>
          <p>On macOS and Linux, run:</p>
          <codeblock outputclass="language-shell">command -v node</codeblock>
          <data name="doc-detective" value='step {"if":"$$platform == windows","runShell":"where node","onSkip":[{"continue":true}]}'/>
          <data name="doc-detective" value='step {"if":"$$platform != windows","runShell":"command -v node","onFail":[{"stop":"test"}]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "if": [
    "$$platform oneOf [linux, mac, windows]"
  ],
  "tests": [
    {
      "testId": "data-node-check",
      "if": [
        "$$platform oneOf [linux, mac, windows]"
      ],
      "publicVariables": [
        "NODE_MAJOR"
      ],
      "steps": [
        {
          "stepId": "node-version",
          "runShell": "node --version",
          "assertions": "$$outputs.stdio.stdout matches /^v[0-9]+\\./",
          "variables": {
            "NODE_MAJOR": "extract($$stdio.stdout, \"v([0-9]+)\")"
          }
        },
        {
          "if": [
            "$$steps.node-version.outputs.exitCode == 0",
            "$$steps.node-version.outputs.stdio.stdout matches /^v/"
          ],
          "runShell": "npm --version",
          "assertions": [
            "$$outputs.exitCode == 0",
            "$NODE_MAJOR >= 18"
          ]
        },
        {
          "if": "$$platform == windows",
          "runShell": "where node",
          "onSkip": [
            {
              "continue": true
            }
          ]
        },
        {
          "if": "$$platform != windows",
          "runShell": "command -v node",
          "onFail": [
            {
              "stop": "test"
            }
          ]
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
if:
  - $$platform oneOf [linux, mac, windows]
tests:
  - testId: data-node-check
    if:
      - $$platform oneOf [linux, mac, windows]
    publicVariables:
      - NODE_MAJOR
    steps:
      - stepId: node-version
        runShell: node --version
        assertions: $$outputs.stdio.stdout matches /^v[0-9]+\./
        variables:
          NODE_MAJOR: extract($$stdio.stdout, "v([0-9]+)")
      - if:
          - $$steps.node-version.outputs.exitCode == 0
          - $$steps.node-version.outputs.stdio.stdout matches /^v/
        runShell: npm --version
        assertions:
          - $$outputs.exitCode == 0
          - $NODE_MAJOR >= 18
      - if: $$platform == windows
        runShell: where node
        onSkip:
          - continue: true
      - if: $$platform != windows
        runShell: command -v node
        onFail:
          - stop: test
```

### How the conditions work

* The test's `if` runs the test only on Linux, macOS, and Windows. The standalone spec sets the same condition on the spec. Both give `if` as an array, whose conditions must all be true. A string `if` holds a single condition, as on the test in the API example and the spec in the next example. A false condition skips the spec, test, or step it's on.
* The first step's `variables` field sets `NODE_MAJOR` from `extract($$stdio.stdout, "v([0-9]+)")`, the major version in the command's output. Its assertion checks the output with `matches`.
* The second step runs only when both conditions in its `if` array hold: the first step exited `0` and its output starts with `v`. `$$steps.node-version.outputs` reads an earlier step's output by its `stepId`. Its assertion `$NODE_MAJOR >= 18` substitutes the variable the first step set.
* The last two steps check `$$platform`, so each platform runs one of them and skips the other. `onSkip` with `continue: true` moves on after the skip, which is also the default. `onFail` with `stop: "test"` stops the test's remaining steps, which is also the default for a failure.

### What detection finds

The commands sit in `shell` code blocks, and default detection turns only `bash`, Python, and JavaScript code blocks into steps, so detection finds none here. Every step comes from a `step` statement, and the detected and inline variants differ only in `detectSteps`.

## Wait for a service, then echo text through it

This procedure has three tests. It uses [`wait`](/docs/actions/wait), [`runShell`](/docs/actions/runshell), [`goTo`](/docs/actions/goto), [`click`](/docs/actions/click), [`type`](/docs/actions/type), [`find`](/docs/actions/find), and [`httpRequest`](/docs/actions/httprequest). It routes with the [step routing](/reference/schemas/step-routing) entries `retry` and `goToStep`, and the [test routing](/reference/schemas/routing) entries `goToTest`, `stop: "spec"`, and `continue`. Several routing entries carry an `if` condition, as a string or an array. It also sets the [context](/reference/schemas/context) field `retries`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Echo text through the service

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

This example simulates a service that isn't ready the first time you check.

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Doc Detective".
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Echo text through the service

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

This example simulates a service that isn't ready the first time you check.

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Doc Detective".
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Echo text through the service

== Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

Check that the service is ready. If the check fails, check again after a short wait:

[source,shell]
----
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
----

This example simulates a service that isn't ready the first time you check.

== Restart the service

If the service still isn't ready, restart it:

[source,shell]
----
node -e "console.log('Restarting the service.')"
----

== Echo text

. Go to http://localhost:8092/type-echo.html[the type echo page].
. Click *Type here:*.
. Type "Hello, Doc Detective".
. Check that the page shows *Hello, Doc Detective* below the field. If it doesn't, type the text again.
. Send the text to the messages API. Send a `+POST+` request to `+http://localhost:8093/api/messages+` with this body:
+
[source,json]
----
{"text": "Hello, Doc Detective"}
----
+
The API returns the same text.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo text through the service</title></head>
<body>
<h1>Echo text through the service</h1>
<h2>Check that the service is ready</h2>

<p>The service can take a few seconds to start, so wait five seconds before you check it.</p>

<p>Check that the service is ready. If the check fails, check again after a short wait:</p>

<pre><code class="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</code></pre>

<p>This example simulates a service that isn't ready the first time you check.</p>
<h2>Restart the service</h2>

<p>If the service still isn't ready, restart it:</p>

<pre><code class="language-shell">node -e "console.log('Restarting the service.')"</code></pre>
<h2>Echo text</h2>

<ol>
  <li>Go to <a href="http://localhost:8092/type-echo.html">the type echo page</a>.</li>
  <li>Click <strong>Type here:</strong>.</li>
  <li>Type "Hello, Doc Detective".</li>
  <li>Check that the page shows <strong>Hello, Doc Detective</strong> below the field. If it doesn't, type the text again.</li>
  <li>Send the text to the messages API. Send a <code>POST</code> request to <code>http://localhost:8093/api/messages</code> with this body:
    <pre><code class="language-json">{"text": "Hello, Doc Detective"}</code></pre>
    <p>The API returns the same text.</p></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Echo text through the service
=============================

Check that the service is ready
-------------------------------

The service can take a few seconds to start, so wait five seconds before you check it.

Check that the service is ready. If the check fails, check again after a short wait:

.. code-block:: shell

   node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"

This example simulates a service that isn't ready the first time you check.

Restart the service
-------------------

If the service still isn't ready, restart it:

.. code-block:: shell

   node -e "console.log('Restarting the service.')"

Echo text
---------

#. Go to `the type echo page <http://localhost:8092/type-echo.html>`_.

#. Click **Type here:**.

#. Type "Hello, Doc Detective".

#. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.

#. Send the text to the messages API. Send a ``POST`` request to ``http://localhost:8093/api/messages`` with this body:

   .. code-block:: json

      {"text": "Hello, Doc Detective"}

   The API returns the same text.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="data-service-retry">
  <title>Echo text through the service</title>
  <body>
    <section>
      <title>Check that the service is ready</title>
      <p>The service can take a few seconds to start, so wait five seconds before you check it.</p>
      <p>Check that the service is ready. If the check fails, check again after a short wait:</p>
      <codeblock outputclass="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</codeblock>
      <p>This example simulates a service that isn't ready the first time you check.</p>
    </section>
    <section>
      <title>Restart the service</title>
      <p>If the service still isn't ready, restart it:</p>
      <codeblock outputclass="language-shell">node -e "console.log('Restarting the service.')"</codeblock>
    </section>
    <section>
      <title>Echo text</title>
      <ol>
        <li>Go to <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref>.</li>
        <li>Click <b>Type here:</b>.</li>
        <li>Type "Hello, Doc Detective".</li>
        <li>Check that the page shows <b>Hello, Doc Detective</b> below the field. If it doesn't, type the text again.</li>
        <li>Send the text to the messages API. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/messages</codeph> with this body:
          <codeblock outputclass="language-json">{"text": "Hello, Doc Detective"}</codeblock>
          <p>The API returns the same text.</p></li>
      </ol>
    </section>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
# Echo text through the service

<!-- test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true} -->

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

<!-- step {"wait":true} -->

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

<!-- step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} -->

This example simulates a service that isn't ready the first time you check.

<!-- test end -->

<!-- test {"testId":"data-service-restart","detectSteps":true} -->

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

<!-- step {"runShell":"node -e \"console.log('Restarting the service.')\""} -->

<!-- test end -->

<!-- test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true} -->

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Doc Detective".
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
   <!-- step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
# Echo text through the service

{/* test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true} */}

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

{/* step {"wait":true} */}

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

{/* step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} */}

This example simulates a service that isn't ready the first time you check.

{/* test end */}

{/* test {"testId":"data-service-restart","detectSteps":true} */}

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

{/* step {"runShell":"node -e \"console.log('Restarting the service.')\""} */}

{/* test end */}

{/* test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true} */}

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Doc Detective".
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
   {/* step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Echo text through the service

// (test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true})

== Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

// (step {"wait":true})

Check that the service is ready. If the check fails, check again after a short wait:

[source,shell]
----
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
----

// (step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]})

This example simulates a service that isn't ready the first time you check.

// (test end)

// (test {"testId":"data-service-restart","detectSteps":true})

== Restart the service

If the service still isn't ready, restart it:

[source,shell]
----
node -e "console.log('Restarting the service.')"
----

// (step {"runShell":"node -e \"console.log('Restarting the service.')\""})

// (test end)

// (test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true})

== Echo text

. Go to http://localhost:8092/type-echo.html[the type echo page].
. Click *Type here:*.
. Type "Hello, Doc Detective".
. Check that the page shows *Hello, Doc Detective* below the field. If it doesn't, type the text again.
. Send the text to the messages API. Send a `+POST+` request to `+http://localhost:8093/api/messages+` with this body:
+
[source,json]
----
{"text": "Hello, Doc Detective"}
----
+
The API returns the same text.
+
// (step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo text through the service</title></head>
<body>
<h1>Echo text through the service</h1>
<!-- test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true} -->
<h2>Check that the service is ready</h2>

<p>The service can take a few seconds to start, so wait five seconds before you check it.</p>

<!-- step {"wait":true} -->

<p>Check that the service is ready. If the check fails, check again after a short wait:</p>

<pre><code class="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</code></pre>

<!-- step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} -->

<p>This example simulates a service that isn't ready the first time you check.</p>
<!-- test end -->
<!-- test {"testId":"data-service-restart","detectSteps":true} -->
<h2>Restart the service</h2>

<p>If the service still isn't ready, restart it:</p>

<pre><code class="language-shell">node -e "console.log('Restarting the service.')"</code></pre>

<!-- step {"runShell":"node -e \"console.log('Restarting the service.')\""} -->
<!-- test end -->
<!-- test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true} -->
<h2>Echo text</h2>

<ol>
  <li>Go to <a href="http://localhost:8092/type-echo.html">the type echo page</a>.</li>
  <li>Click <strong>Type here:</strong>.</li>
  <li>Type "Hello, Doc Detective".</li>
  <li>Check that the page shows <strong>Hello, Doc Detective</strong> below the field. If it doesn't, type the text again.</li>
  <li>Send the text to the messages API. Send a <code>POST</code> request to <code>http://localhost:8093/api/messages</code> with this body:
    <pre><code class="language-json">{"text": "Hello, Doc Detective"}</code></pre>
    <p>The API returns the same text.</p>
    <!-- step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Echo text through the service
=============================

.. test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true}

Check that the service is ready
-------------------------------

The service can take a few seconds to start, so wait five seconds before you check it.

.. step {"wait":true}

Check that the service is ready. If the check fails, check again after a short wait:

.. code-block:: shell

   node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"

.. step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]}

This example simulates a service that isn't ready the first time you check.

.. test end

.. test {"testId":"data-service-restart","detectSteps":true}

Restart the service
-------------------

If the service still isn't ready, restart it:

.. code-block:: shell

   node -e "console.log('Restarting the service.')"

.. step {"runShell":"node -e \"console.log('Restarting the service.')\""}

.. test end

.. test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true}

Echo text
---------

#. Go to `the type echo page <http://localhost:8092/type-echo.html>`_.

#. Click **Type here:**.

#. Type "Hello, Doc Detective".

#. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.

#. Send the text to the messages API. Send a ``POST`` request to ``http://localhost:8093/api/messages`` with this body:

   .. code-block:: json

      {"text": "Hello, Doc Detective"}

   The API returns the same text.

   .. step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="data-service-retry">
  <title>Echo text through the service</title>
  <body>
    <section>
      <title>Check that the service is ready</title>
      <data name="doc-detective" value='test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":true}'/>
      <p>The service can take a few seconds to start, so wait five seconds before you check it.</p>
      <data name="doc-detective" value='step {"wait":true}'/>
      <p>Check that the service is ready. If the check fails, check again after a short wait:</p>
      <codeblock outputclass="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</codeblock>
      <data name="doc-detective" value='step {"runShell":"node -e \"const fs=require(&apos;fs&apos;),f=require(&apos;path&apos;).join(require(&apos;os&apos;).tmpdir(),&apos;doc-detective-docs-ready&apos;);if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,&apos;&apos;);console.error(&apos;Not ready yet.&apos;);process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]}'/>
      <p>This example simulates a service that isn't ready the first time you check.</p>
      <data name="doc-detective" value="test end"/>
    </section>
    <section>
      <title>Restart the service</title>
      <data name="doc-detective" value='test {"testId":"data-service-restart","detectSteps":true}'/>
      <p>If the service still isn't ready, restart it:</p>
      <codeblock outputclass="language-shell">node -e "console.log('Restarting the service.')"</codeblock>
      <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;Restarting the service.&apos;)\""}'/>
      <data name="doc-detective" value="test end"/>
    </section>
    <section>
      <title>Echo text</title>
      <data name="doc-detective" value='test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":true}'/>
      <ol>
        <li>Go to <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref>.</li>
        <li>Click <b>Type here:</b>.</li>
        <li>Type "Hello, Doc Detective".</li>
        <li>Check that the page shows <b>Hello, Doc Detective</b> below the field. If it doesn't, type the text again.</li>
        <li>Send the text to the messages API. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/messages</codeph> with this body:
          <codeblock outputclass="language-json">{"text": "Hello, Doc Detective"}</codeblock>
          <p>The API returns the same text.</p>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"Hello, Doc Detective"}},"response":{"body":{"text":"Hello, Doc Detective"}}}}'/></li>
      </ol>
      <data name="doc-detective" value="test end"/>
    </section>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
# Echo text through the service

<!-- test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false} -->

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

<!-- step {"wait":true} -->

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

<!-- step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} -->

This example simulates a service that isn't ready the first time you check.

<!-- test end -->

<!-- test {"testId":"data-service-restart","detectSteps":false} -->

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

<!-- step {"runShell":"node -e \"console.log('Restarting the service.')\""} -->

<!-- test end -->

<!-- test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false} -->

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Click **Type here:**.
   <!-- step {"click":"Type here:"} -->
3. Type "Hello, Doc Detective".
   <!-- step {"type":"Hello, Doc Detective"} -->
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
   <!-- step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]} -->
   <!-- step {"stepId":"retype","type":"Hello, Doc Detective"} -->
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
   <!-- step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
# Echo text through the service

{/* test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false} */}

## Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

{/* step {"wait":true} */}

Check that the service is ready. If the check fails, check again after a short wait:

```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

{/* step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} */}

This example simulates a service that isn't ready the first time you check.

{/* test end */}

{/* test {"testId":"data-service-restart","detectSteps":false} */}

## Restart the service

If the service still isn't ready, restart it:

```shell
node -e "console.log('Restarting the service.')"
```

{/* step {"runShell":"node -e \"console.log('Restarting the service.')\""} */}

{/* test end */}

{/* test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false} */}

## Echo text

1. Go to [the type echo page](http://localhost:8092/type-echo.html).
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Click **Type here:**.
   {/* step {"click":"Type here:"} */}
3. Type "Hello, Doc Detective".
   {/* step {"type":"Hello, Doc Detective"} */}
4. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.
   {/* step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]} */}
   {/* step {"stepId":"retype","type":"Hello, Doc Detective"} */}
5. Send the text to the messages API. Send a `POST` request to `http://localhost:8093/api/messages` with this body:

   ```json
   {"text": "Hello, Doc Detective"}
   ```

   The API returns the same text.
   {/* step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Echo text through the service

// (test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false})

== Check that the service is ready

The service can take a few seconds to start, so wait five seconds before you check it.

// (step {"wait":true})

Check that the service is ready. If the check fails, check again after a short wait:

[source,shell]
----
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
----

// (step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]})

This example simulates a service that isn't ready the first time you check.

// (test end)

// (test {"testId":"data-service-restart","detectSteps":false})

== Restart the service

If the service still isn't ready, restart it:

[source,shell]
----
node -e "console.log('Restarting the service.')"
----

// (step {"runShell":"node -e \"console.log('Restarting the service.')\""})

// (test end)

// (test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false})

== Echo text

. Go to http://localhost:8092/type-echo.html[the type echo page].
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Click *Type here:*.
+
// (step {"click":"Type here:"})
. Type "Hello, Doc Detective".
+
// (step {"type":"Hello, Doc Detective"})
. Check that the page shows *Hello, Doc Detective* below the field. If it doesn't, type the text again.
+
// (step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]})
+
// (step {"stepId":"retype","type":"Hello, Doc Detective"})
. Send the text to the messages API. Send a `+POST+` request to `+http://localhost:8093/api/messages+` with this body:
+
[source,json]
----
{"text": "Hello, Doc Detective"}
----
+
The API returns the same text.
+
// (step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo text through the service</title></head>
<body>
<h1>Echo text through the service</h1>
<!-- test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false} -->
<h2>Check that the service is ready</h2>

<p>The service can take a few seconds to start, so wait five seconds before you check it.</p>

<!-- step {"wait":true} -->

<p>Check that the service is ready. If the check fails, check again after a short wait:</p>

<pre><code class="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</code></pre>

<!-- step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]} -->

<p>This example simulates a service that isn't ready the first time you check.</p>
<!-- test end -->
<!-- test {"testId":"data-service-restart","detectSteps":false} -->
<h2>Restart the service</h2>

<p>If the service still isn't ready, restart it:</p>

<pre><code class="language-shell">node -e "console.log('Restarting the service.')"</code></pre>

<!-- step {"runShell":"node -e \"console.log('Restarting the service.')\""} -->
<!-- test end -->
<!-- test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false} -->
<h2>Echo text</h2>

<ol>
  <li>Go to <a href="http://localhost:8092/type-echo.html">the type echo page</a>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Click <strong>Type here:</strong>.
    <!-- step {"click":"Type here:"} --></li>
  <li>Type "Hello, Doc Detective".
    <!-- step {"type":"Hello, Doc Detective"} --></li>
  <li>Check that the page shows <strong>Hello, Doc Detective</strong> below the field. If it doesn't, type the text again.
    <!-- step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]} -->
    <!-- step {"stepId":"retype","type":"Hello, Doc Detective"} --></li>
  <li>Send the text to the messages API. Send a <code>POST</code> request to <code>http://localhost:8093/api/messages</code> with this body:
    <pre><code class="language-json">{"text": "Hello, Doc Detective"}</code></pre>
    <p>The API returns the same text.</p>
    <!-- step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Echo text through the service
=============================

.. test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false}

Check that the service is ready
-------------------------------

The service can take a few seconds to start, so wait five seconds before you check it.

.. step {"wait":true}

Check that the service is ready. If the check fails, check again after a short wait:

.. code-block:: shell

   node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"

.. step {"runShell":"node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]}

This example simulates a service that isn't ready the first time you check.

.. test end

.. test {"testId":"data-service-restart","detectSteps":false}

Restart the service
-------------------

If the service still isn't ready, restart it:

.. code-block:: shell

   node -e "console.log('Restarting the service.')"

.. step {"runShell":"node -e \"console.log('Restarting the service.')\""}

.. test end

.. test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false}

Echo text
---------

#. Go to `the type echo page <http://localhost:8092/type-echo.html>`_.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Click **Type here:**.

   .. step {"click":"Type here:"}

#. Type "Hello, Doc Detective".

   .. step {"type":"Hello, Doc Detective"}

#. Check that the page shows **Hello, Doc Detective** below the field. If it doesn't, type the text again.

   .. step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]}

   .. step {"stepId":"retype","type":"Hello, Doc Detective"}

#. Send the text to the messages API. Send a ``POST`` request to ``http://localhost:8093/api/messages`` with this body:

   .. code-block:: json

      {"text": "Hello, Doc Detective"}

   The API returns the same text.

   .. step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="data-service-retry">
  <title>Echo text through the service</title>
  <body>
    <section>
      <title>Check that the service is ready</title>
      <data name="doc-detective" value='test {"testId":"data-service-ready","onPass":[{"if":["$$platform oneOf [linux, mac, windows]"],"goToTest":"data-echo-text"}],"onFail":[{"if":"$$platform oneOf [linux, mac, windows]","stop":"spec"}],"detectSteps":false}'/>
      <p>The service can take a few seconds to start, so wait five seconds before you check it.</p>
      <data name="doc-detective" value='step {"wait":true}'/>
      <p>Check that the service is ready. If the check fails, check again after a short wait:</p>
      <codeblock outputclass="language-shell">node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"</codeblock>
      <data name="doc-detective" value='step {"runShell":"node -e \"const fs=require(&apos;fs&apos;),f=require(&apos;path&apos;).join(require(&apos;os&apos;).tmpdir(),&apos;doc-detective-docs-ready&apos;);if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,&apos;&apos;);console.error(&apos;Not ready yet.&apos;);process.exit(1)}\"","onFail":[{"if":"$$outputs.exitCode == 1","retry":{"limit":3,"delay":500,"backoff":"exponential"}}]}'/>
      <p>This example simulates a service that isn't ready the first time you check.</p>
      <data name="doc-detective" value="test end"/>
    </section>
    <section>
      <title>Restart the service</title>
      <data name="doc-detective" value='test {"testId":"data-service-restart","detectSteps":false}'/>
      <p>If the service still isn't ready, restart it:</p>
      <codeblock outputclass="language-shell">node -e "console.log('Restarting the service.')"</codeblock>
      <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;Restarting the service.&apos;)\""}'/>
      <data name="doc-detective" value="test end"/>
    </section>
    <section>
      <title>Echo text</title>
      <data name="doc-detective" value='test {"testId":"data-echo-text","publicVariables":["ECHOED"],"contexts":[{"retries":2}],"onWarning":[{"continue":true}],"onSkip":[{"stop":"spec"}],"detectSteps":false}'/>
      <ol>
        <li>Go to <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref>.
          <data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></li>
        <li>Click <b>Type here:</b>.
          <data name="doc-detective" value='step {"click":"Type here:"}'/></li>
        <li>Type "Hello, Doc Detective".
          <data name="doc-detective" value='step {"type":"Hello, Doc Detective"}'/></li>
        <li>Check that the page shows <b>Hello, Doc Detective</b> below the field. If it doesn't, type the text again.
          <data name="doc-detective" value='step {"stepId":"read-echo","find":{"selector":"#echo","elementText":"Hello, Doc Detective"},"variables":{"ECHOED":"$$element.text"},"onPass":[{"if":["$$outputs.element.text == \"Hello, Doc Detective\""],"goToStep":"send-echo"}],"onFail":[{"retry":{"limit":2,"delay":500}}]}'/>
          <data name="doc-detective" value='step {"stepId":"retype","type":"Hello, Doc Detective"}'/></li>
        <li>Send the text to the messages API. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/messages</codeph> with this body:
          <codeblock outputclass="language-json">{"text": "Hello, Doc Detective"}</codeblock>
          <p>The API returns the same text.</p>
          <data name="doc-detective" value='step {"stepId":"send-echo","if":"$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"","httpRequest":{"url":"http://localhost:8093/api/messages","method":"post","request":{"body":{"text":"$ECHOED"}},"response":{"body":{"text":"Hello, Doc Detective"}}},"assertions":"$$outputs.response.body.text == \"$ECHOED\"","onWarning":[{"continue":true}]}'/></li>
      </ol>
      <data name="doc-detective" value="test end"/>
    </section>
  </body>
</topic>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "if": "$$platform oneOf [linux, mac, windows]",
  "tests": [
    {
      "testId": "data-service-ready",
      "onPass": [
        {
          "if": [
            "$$platform oneOf [linux, mac, windows]"
          ],
          "goToTest": "data-echo-text"
        }
      ],
      "onFail": [
        {
          "if": "$$platform oneOf [linux, mac, windows]",
          "stop": "spec"
        }
      ],
      "steps": [
        {
          "wait": true
        },
        {
          "runShell": "node -e \"const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}\"",
          "onFail": [
            {
              "if": "$$outputs.exitCode == 1",
              "retry": {
                "limit": 3,
                "delay": 500,
                "backoff": "exponential"
              }
            }
          ]
        }
      ]
    },
    {
      "testId": "data-service-restart",
      "steps": [
        {
          "runShell": "node -e \"console.log('Restarting the service.')\""
        }
      ]
    },
    {
      "testId": "data-echo-text",
      "publicVariables": [
        "ECHOED"
      ],
      "contexts": [
        {
          "retries": 2
        }
      ],
      "onWarning": [
        {
          "continue": true
        }
      ],
      "onSkip": [
        {
          "stop": "spec"
        }
      ],
      "steps": [
        {
          "goTo": "http://localhost:8092/type-echo.html"
        },
        {
          "click": "Type here:"
        },
        {
          "type": "Hello, Doc Detective"
        },
        {
          "stepId": "read-echo",
          "find": {
            "selector": "#echo",
            "elementText": "Hello, Doc Detective"
          },
          "variables": {
            "ECHOED": "$$element.text"
          },
          "onPass": [
            {
              "if": [
                "$$outputs.element.text == \"Hello, Doc Detective\""
              ],
              "goToStep": "send-echo"
            }
          ],
          "onFail": [
            {
              "retry": {
                "limit": 2,
                "delay": 500
              }
            }
          ]
        },
        {
          "stepId": "retype",
          "type": "Hello, Doc Detective"
        },
        {
          "stepId": "send-echo",
          "if": "$$steps.read-echo.outputs.element.text == \"Hello, Doc Detective\"",
          "httpRequest": {
            "url": "http://localhost:8093/api/messages",
            "method": "post",
            "request": {
              "body": {
                "text": "$ECHOED"
              }
            },
            "response": {
              "body": {
                "text": "Hello, Doc Detective"
              }
            }
          },
          "assertions": "$$outputs.response.body.text == \"$ECHOED\"",
          "onWarning": [
            {
              "continue": true
            }
          ]
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
if: $$platform oneOf [linux, mac, windows]
tests:
  - testId: data-service-ready
    onPass:
      - if:
          - $$platform oneOf [linux, mac, windows]
        goToTest: data-echo-text
    onFail:
      - if: $$platform oneOf [linux, mac, windows]
        stop: spec
    steps:
      - wait: true
      - runShell: node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'doc-detective-docs-ready');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
        onFail:
          - if: $$outputs.exitCode == 1
            retry:
              limit: 3
              delay: 500
              backoff: exponential
  - testId: data-service-restart
    steps:
      - runShell: node -e "console.log('Restarting the service.')"
  - testId: data-echo-text
    publicVariables:
      - ECHOED
    contexts:
      - retries: 2
    onWarning:
      - continue: true
    onSkip:
      - stop: spec
    steps:
      - goTo: http://localhost:8092/type-echo.html
      - click: "Type here:"
      - type: Hello, Doc Detective
      - stepId: read-echo
        find:
          selector: "#echo"
          elementText: Hello, Doc Detective
        variables:
          ECHOED: $$element.text
        onPass:
          - if:
              - $$outputs.element.text == "Hello, Doc Detective"
            goToStep: send-echo
        onFail:
          - retry:
              limit: 2
              delay: 500
      - stepId: retype
        type: Hello, Doc Detective
      - stepId: send-echo
        if: $$steps.read-echo.outputs.element.text == "Hello, Doc Detective"
        httpRequest:
          url: http://localhost:8093/api/messages
          method: post
          request:
            body:
              text: $ECHOED
          response:
            body:
              text: Hello, Doc Detective
        assertions: $$outputs.response.body.text == "$ECHOED"
        onWarning:
          - continue: true
```

### How the routing works

First, `wait: true` pauses for 5000 milliseconds, the default for `wait`. A number sets the pause in milliseconds instead.

The readiness check then fails on purpose the first time it runs, and the test still passes:

1. The check exits `1` and prints `Not ready yet.`
2. Its `onFail` entry applies only when `$$outputs.exitCode == 1`, so a different exit code falls through to the default and stops the test. The entry's `retry` runs the check again after 500 milliseconds, up to 3 more times, with `exponential` backoff between runs.
3. The second run exits `0`, so the step passes. Its result reports `"attempts": 2`.

A step that a `retry` brings back to passing counts as passed. Other routing doesn't change a result: a step that fails and then routes with `continue` or `goToStep` still fails its test.

The rest of the routing:

* The first test's `onPass` entry `goToTest` jumps to `data-echo-text`, so `data-service-restart` doesn't run and doesn't appear in the results. If the check still fails after its retries, the `onFail` entry `stop: "spec"` skips the spec's remaining tests. A test routing entry's `if` reads `$$platform`. Here it's an array on `onPass` and a string on `onFail`, and both are true on every supported platform.
* In `data-echo-text`, the `read-echo` step saves the element's text from `$$element.text`. When it passes and its text matches the `if` array of its `onPass` entry, `goToStep` jumps over the `retype` step to `send-echo`. When it fails, `retry` runs it again.
* `send-echo` runs only when `$$steps.read-echo.outputs.element.text` matches, sends the saved `$ECHOED` value, and asserts that the response echoes it. The test's `publicVariables` shows `ECHOED` in output instead of masking it.
* `onWarning` with `continue: true`, on `send-echo` and on the test, moves on after a warning, which is also the default. The test's `onSkip` entry `stop: "spec"` skips the spec's remaining tests if Doc Detective skips this test.
* The context's `retries: 2` runs the whole test again on a fresh browser session, up to twice, when the session crashes or never loads a page. A real failure, such as a missing element, doesn't trigger it. A step's `retry` runs one step again on the same session.

A step that `retry` or `goToStep` runs more than once reports `attempts` or `visit` in its result. A test that `goToTest` runs again reports `visit`. Doc Detective sets these fields. Don't set them in a test.

### What detection finds

In the first two tests, the commands sit in `shell` code blocks, which default detection doesn't run, so their steps come from `step` statements.

In `data-echo-text`, detection resolves the prose to six steps:

| Prose               | Detected steps                                  |
| ------------------- | ----------------------------------------------- |
| Go to a link        | `goTo` the URL, then `checkLink` the same URL   |
| Click a bold phrase | `click` the phrase, then `find` the same phrase |
| `type "…"`          | `type` the quoted text                          |
| A bold phrase       | `find` the phrase                               |

A `step` statement adds the `httpRequest`, which sends the literal text because no detected step saves it. The detected `data-echo-text` has no `retype` step or step routing: those live on steps that only the inline and standalone variants write out.

## About the permutations

Each example below varies one setting in a short procedure. Detection finds no steps in these procedures, because the URLs and commands sit in code. So every variant runs the same `step` statements, and the detected and inline files differ only in `detectSteps`.

For `onPass`, `onFail`, `onWarning`, and `onSkip`, see [Step routing](/reference/docs-as-tests/step-routing) and [Test routing](/reference/docs-as-tests/test-routing).

## `loadVariables` permutations

### Step, file next to the test

**Varies:** `step.loadVariables` · **Value:** `"service.env"` · **Effect:** the step loads `service.env` from the test file's folder, and later steps substitute `$SERVICE_URL`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check a service from an environment file

1. Load the variables in `service.env`.
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check a service from an environment file

1. Load the variables in `service.env`.
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check a service from an environment file

. Load the variables in `+service.env+`.
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file</title></head>
<body>
<h1>Check a service from an environment file</h1>
<ol>
  <li>Load the variables in <code>service.env</code>.</li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check a service from an environment file
========================================

#. Load the variables in ``service.env``.

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step">
  <title>Check a service from an environment file</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>service.env</codeph>.</cmd></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-loadvariables-step","detectSteps":true} -->

# Check a service from an environment file

1. Load the variables in `service.env`.
   <!-- step {"loadVariables":"service.env"} -->
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-loadvariables-step","detectSteps":true} */}

# Check a service from an environment file

1. Load the variables in `service.env`.
   {/* step {"loadVariables":"service.env"} */}
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check a service from an environment file

// (test {"testId":"data-loadvariables-step","detectSteps":true})

. Load the variables in `+service.env+`.
+
// (step {"loadVariables":"service.env"})
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file</title></head>
<body>
<!-- test {"testId":"data-loadvariables-step","detectSteps":true} -->
<h1>Check a service from an environment file</h1>
<ol>
  <li>Load the variables in <code>service.env</code>.
    <!-- step {"loadVariables":"service.env"} --></li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check a service from an environment file
========================================

.. test {"testId":"data-loadvariables-step","detectSteps":true}

#. Load the variables in ``service.env``.

   .. step {"loadVariables":"service.env"}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step">
  <title>Check a service from an environment file</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-step","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>service.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"service.env"}'/></info></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-loadvariables-step","detectSteps":false} -->

# Check a service from an environment file

1. Load the variables in `service.env`.
   <!-- step {"loadVariables":"service.env"} -->
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-loadvariables-step","detectSteps":false} */}

# Check a service from an environment file

1. Load the variables in `service.env`.
   {/* step {"loadVariables":"service.env"} */}
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check a service from an environment file

// (test {"testId":"data-loadvariables-step","detectSteps":false})

. Load the variables in `+service.env+`.
+
// (step {"loadVariables":"service.env"})
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file</title></head>
<body>
<!-- test {"testId":"data-loadvariables-step","detectSteps":false} -->
<h1>Check a service from an environment file</h1>
<ol>
  <li>Load the variables in <code>service.env</code>.
    <!-- step {"loadVariables":"service.env"} --></li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check a service from an environment file
========================================

.. test {"testId":"data-loadvariables-step","detectSteps":false}

#. Load the variables in ``service.env``.

   .. step {"loadVariables":"service.env"}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step">
  <title>Check a service from an environment file</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-step","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>service.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"service.env"}'/></info></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-loadvariables-step",
      "steps": [
        {
          "loadVariables": "service.env"
        },
        {
          "httpRequest": {
            "url": "$SERVICE_URL/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-loadvariables-step
    steps:
      - loadVariables: service.env
      - httpRequest:
          url: $SERVICE_URL/health
          method: get
```

### Step, file in a child folder

**Varies:** `step.loadVariables` · **Value:** `"env/service.env"` · **Effect:** a relative path resolves from the test file's folder, so the step loads `env/service.env` below it.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check a service from an environment file in a child folder

. Load the variables in `+env/service.env+`.
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file in a child folder</title></head>
<body>
<h1>Check a service from an environment file in a child folder</h1>
<ol>
  <li>Load the variables in <code>env/service.env</code>.</li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check a service from an environment file in a child folder
==========================================================

#. Load the variables in ``env/service.env``.

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step-subfolder">
  <title>Check a service from an environment file in a child folder</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>env/service.env</codeph>.</cmd></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-loadvariables-step-subfolder","detectSteps":true} -->

# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
   <!-- step {"loadVariables":"env/service.env"} -->
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-loadvariables-step-subfolder","detectSteps":true} */}

# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
   {/* step {"loadVariables":"env/service.env"} */}
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check a service from an environment file in a child folder

// (test {"testId":"data-loadvariables-step-subfolder","detectSteps":true})

. Load the variables in `+env/service.env+`.
+
// (step {"loadVariables":"env/service.env"})
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file in a child folder</title></head>
<body>
<!-- test {"testId":"data-loadvariables-step-subfolder","detectSteps":true} -->
<h1>Check a service from an environment file in a child folder</h1>
<ol>
  <li>Load the variables in <code>env/service.env</code>.
    <!-- step {"loadVariables":"env/service.env"} --></li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check a service from an environment file in a child folder
==========================================================

.. test {"testId":"data-loadvariables-step-subfolder","detectSteps":true}

#. Load the variables in ``env/service.env``.

   .. step {"loadVariables":"env/service.env"}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step-subfolder">
  <title>Check a service from an environment file in a child folder</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-step-subfolder","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>env/service.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"env/service.env"}'/></info></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-loadvariables-step-subfolder","detectSteps":false} -->

# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
   <!-- step {"loadVariables":"env/service.env"} -->
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-loadvariables-step-subfolder","detectSteps":false} */}

# Check a service from an environment file in a child folder

1. Load the variables in `env/service.env`.
   {/* step {"loadVariables":"env/service.env"} */}
2. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check a service from an environment file in a child folder

// (test {"testId":"data-loadvariables-step-subfolder","detectSteps":false})

. Load the variables in `+env/service.env+`.
+
// (step {"loadVariables":"env/service.env"})
. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service from an environment file in a child folder</title></head>
<body>
<!-- test {"testId":"data-loadvariables-step-subfolder","detectSteps":false} -->
<h1>Check a service from an environment file in a child folder</h1>
<ol>
  <li>Load the variables in <code>env/service.env</code>.
    <!-- step {"loadVariables":"env/service.env"} --></li>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check a service from an environment file in a child folder
==========================================================

.. test {"testId":"data-loadvariables-step-subfolder","detectSteps":false}

#. Load the variables in ``env/service.env``.

   .. step {"loadVariables":"env/service.env"}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-step-subfolder">
  <title>Check a service from an environment file in a child folder</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-step-subfolder","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>env/service.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"env/service.env"}'/></info></step>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-loadvariables-step-subfolder",
      "steps": [
        {
          "loadVariables": "env/service.env"
        },
        {
          "httpRequest": {
            "url": "$SERVICE_URL/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-loadvariables-step-subfolder
    steps:
      - loadVariables: env/service.env
      - httpRequest:
          url: $SERVICE_URL/health
          method: get
```

### In the config file

**Varies:** `config.loadVariables` · **Value:** `"service.env"` · **Effect:** the example's `doc-detective.json` loads the file before any test runs, so no step loads it. A relative path resolves from the config file's folder.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check a service with variables from the config

. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service with variables from the config</title></head>
<body>
<h1>Check a service with variables from the config</h1>
<ol>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check a service with variables from the config
==============================================

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-config">
  <title>Check a service with variables from the config</title>
  <taskbody>
    <steps>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-loadvariables-config","detectSteps":true} -->

# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-loadvariables-config","detectSteps":true} */}

# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check a service with variables from the config

// (test {"testId":"data-loadvariables-config","detectSteps":true})

. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service with variables from the config</title></head>
<body>
<!-- test {"testId":"data-loadvariables-config","detectSteps":true} -->
<h1>Check a service with variables from the config</h1>
<ol>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check a service with variables from the config
==============================================

.. test {"testId":"data-loadvariables-config","detectSteps":true}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-config">
  <title>Check a service with variables from the config</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-config","detectSteps":true}'/>
    <steps>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-loadvariables-config","detectSteps":false} -->

# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-loadvariables-config","detectSteps":false} */}

# Check a service with variables from the config

1. Check the service. Send a `GET` request to `$SERVICE_URL/health`.
   {/* step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check a service with variables from the config

// (test {"testId":"data-loadvariables-config","detectSteps":false})

. Check the service. Send a `+GET+` request to `+$SERVICE_URL/health+`.
+
// (step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a service with variables from the config</title></head>
<body>
<!-- test {"testId":"data-loadvariables-config","detectSteps":false} -->
<h1>Check a service with variables from the config</h1>
<ol>
  <li>Check the service. Send a <code>GET</code> request to <code>$SERVICE_URL/health</code>.
    <!-- step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check a service with variables from the config
==============================================

.. test {"testId":"data-loadvariables-config","detectSteps":false}

#. Check the service. Send a ``GET`` request to ``$SERVICE_URL/health``.

   .. step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-loadvariables-config">
  <title>Check a service with variables from the config</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-loadvariables-config","detectSteps":false}'/>
    <steps>
      <step><cmd>Check the service. Send a <codeph>GET</codeph> request to <codeph>$SERVICE_URL/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SERVICE_URL/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-loadvariables-config",
      "steps": [
        {
          "httpRequest": {
            "url": "$SERVICE_URL/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-loadvariables-config
    steps:
      - httpRequest:
          url: $SERVICE_URL/health
          method: get
```

## `variables` expression permutations

### `$$response`

**Varies:** `step.variables` · **Value:** `{"ORDER_ID": "$$response.body.id"}` · **Effect:** saves a field of the HTTP response body, and the next request sends it as a query parameter.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create an order and look it up

. Create an order. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with this body:
+
[source,json]
----
{"id":"ord-1001"}
----
. Look up the order. Send a `+GET+` request to `+http://localhost:8092/api/orders?id=<id>+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an order and look it up</title></head>
<body>
<h1>Create an order and look it up</h1>
<ol>
  <li>Create an order. Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with this body:
    <pre><code class="language-json">{"id":"ord-1001"}</code></pre></li>
  <li>Look up the order. Send a <code>GET</code> request to <code>http://localhost:8092/api/orders?id=&lt;id&gt;</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create an order and look it up
==============================

#. Create an order. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with this body:

   .. code-block:: json

      {"id":"ord-1001"}

#. Look up the order. Send a ``GET`` request to ``http://localhost:8092/api/orders?id=<id>``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-response">
  <title>Create an order and look it up</title>
  <taskbody>
    <steps>
      <step><cmd>Create an order. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"id":"ord-1001"}</codeblock></info></step>
      <step><cmd>Look up the order. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/orders?id=&lt;id&gt;</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-variables-response","detectSteps":true} -->

# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} -->
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-variables-response","detectSteps":true} */}

# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} */}
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create an order and look it up

// (test {"testId":"data-variables-response","detectSteps":true})

. Create an order. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with this body:
+
[source,json]
----
{"id":"ord-1001"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}})
. Look up the order. Send a `+GET+` request to `+http://localhost:8092/api/orders?id=<id>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an order and look it up</title></head>
<body>
<!-- test {"testId":"data-variables-response","detectSteps":true} -->
<h1>Create an order and look it up</h1>
<ol>
  <li>Create an order. Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with this body:
    <pre><code class="language-json">{"id":"ord-1001"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} --></li>
  <li>Look up the order. Send a <code>GET</code> request to <code>http://localhost:8092/api/orders?id=&lt;id&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create an order and look it up
==============================

.. test {"testId":"data-variables-response","detectSteps":true}

#. Create an order. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with this body:

   .. code-block:: json

      {"id":"ord-1001"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}}

#. Look up the order. Send a ``GET`` request to ``http://localhost:8092/api/orders?id=<id>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-response">
  <title>Create an order and look it up</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-response","detectSteps":true}'/>
    <steps>
      <step><cmd>Create an order. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"id":"ord-1001"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}}'/></info></step>
      <step><cmd>Look up the order. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/orders?id=&lt;id&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-variables-response","detectSteps":false} -->

# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} -->
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-variables-response","detectSteps":false} */}

# Create an order and look it up

1. Create an order. Send a `POST` request to `http://localhost:8092/api/orders` with this body:

   ```json
   {"id":"ord-1001"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} */}
2. Look up the order. Send a `GET` request to `http://localhost:8092/api/orders?id=<id>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create an order and look it up

// (test {"testId":"data-variables-response","detectSteps":false})

. Create an order. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with this body:
+
[source,json]
----
{"id":"ord-1001"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}})
. Look up the order. Send a `+GET+` request to `+http://localhost:8092/api/orders?id=<id>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an order and look it up</title></head>
<body>
<!-- test {"testId":"data-variables-response","detectSteps":false} -->
<h1>Create an order and look it up</h1>
<ol>
  <li>Create an order. Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with this body:
    <pre><code class="language-json">{"id":"ord-1001"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}} --></li>
  <li>Look up the order. Send a <code>GET</code> request to <code>http://localhost:8092/api/orders?id=&lt;id&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create an order and look it up
==============================

.. test {"testId":"data-variables-response","detectSteps":false}

#. Create an order. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with this body:

   .. code-block:: json

      {"id":"ord-1001"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}}

#. Look up the order. Send a ``GET`` request to ``http://localhost:8092/api/orders?id=<id>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-response">
  <title>Create an order and look it up</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-response","detectSteps":false}'/>
    <steps>
      <step><cmd>Create an order. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"id":"ord-1001"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"id":"ord-1001"}}},"variables":{"ORDER_ID":"$$response.body.id"}}'/></info></step>
      <step><cmd>Look up the order. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/orders?id=&lt;id&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders?id=$ORDER_ID","method":"get","response":{"body":{"id":"ord-1001"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-response",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/orders",
            "method": "post",
            "request": {
              "body": {
                "id": "ord-1001"
              }
            }
          },
          "variables": {
            "ORDER_ID": "$$response.body.id"
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/orders?id=$ORDER_ID",
            "method": "get",
            "response": {
              "body": {
                "id": "ord-1001"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-response
    steps:
      - httpRequest:
          url: http://localhost:8092/api/orders
          method: post
          request:
            body:
              id: ord-1001
        variables:
          ORDER_ID: $$response.body.id
      - httpRequest:
          url: http://localhost:8092/api/orders?id=$ORDER_ID
          method: get
          response:
            body:
              id: ord-1001
```

### `$$stdio`

**Varies:** `step.variables` · **Value:** `{"NODE_VERSION": "$$stdio.stdout"}` · **Effect:** saves the command's output, and the next command reads it from its environment.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save the Node.js version

. Print the Node.js version:
+
[source,shell]
----
node --version
----
. Check that the saved version starts with `+v+`:
+
[source,shell]
----
node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js version</title></head>
<body>
<h1>Save the Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre></li>
  <li>Check that the saved version starts with <code>v</code>:
    <pre><code class="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save the Node.js version
========================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

#. Check that the saved version starts with ``v``:

   .. code-block:: shell

      node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-stdio">
  <title>Save the Node.js version</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock></info></step>
      <step><cmd>Check that the saved version starts with <codeph>v</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-variables-stdio","detectSteps":true} -->

# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} -->
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
   <!-- step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-variables-stdio","detectSteps":true} */}

# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} */}
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
   {/* step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save the Node.js version

// (test {"testId":"data-variables-stdio","detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}})
. Check that the saved version starts with `+v+`:
+
[source,shell]
----
node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
----
+
// (step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js version</title></head>
<body>
<!-- test {"testId":"data-variables-stdio","detectSteps":true} -->
<h1>Save the Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} --></li>
  <li>Check that the saved version starts with <code>v</code>:
    <pre><code class="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</code></pre>
    <!-- step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save the Node.js version
========================

.. test {"testId":"data-variables-stdio","detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}}

#. Check that the saved version starts with ``v``:

   .. code-block:: shell

      node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"

   .. step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-stdio">
  <title>Save the Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-stdio","detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}}'/></info></step>
      <step><cmd>Check that the saved version starts with <codeph>v</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</codeblock>
          <data name="doc-detective" value='step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith(&apos;v&apos;) ? 0 : 1)\""}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-variables-stdio","detectSteps":false} -->

# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} -->
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
   <!-- step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-variables-stdio","detectSteps":false} */}

# Save the Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} */}
2. Check that the saved version starts with `v`:

   ```shell
   node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
   ```
   {/* step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save the Node.js version

// (test {"testId":"data-variables-stdio","detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}})
. Check that the saved version starts with `+v+`:
+
[source,shell]
----
node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"
----
+
// (step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js version</title></head>
<body>
<!-- test {"testId":"data-variables-stdio","detectSteps":false} -->
<h1>Save the Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}} --></li>
  <li>Check that the saved version starts with <code>v</code>:
    <pre><code class="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</code></pre>
    <!-- step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save the Node.js version
========================

.. test {"testId":"data-variables-stdio","detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}}

#. Check that the saved version starts with ``v``:

   .. code-block:: shell

      node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"

   .. step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-stdio">
  <title>Save the Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-stdio","detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","variables":{"NODE_VERSION":"$$stdio.stdout"}}'/></info></step>
      <step><cmd>Check that the saved version starts with <codeph>v</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)"</codeblock>
          <data name="doc-detective" value='step {"runShell":"node -e \"process.exit(process.env.NODE_VERSION.startsWith(&apos;v&apos;) ? 0 : 1)\""}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-stdio",
      "steps": [
        {
          "runShell": "node --version",
          "variables": {
            "NODE_VERSION": "$$stdio.stdout"
          }
        },
        {
          "runShell": "node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-stdio
    steps:
      - runShell: node --version
        variables:
          NODE_VERSION: $$stdio.stdout
      - runShell: "node -e \"process.exit(process.env.NODE_VERSION.startsWith('v') ? 0 : 1)\""
```

### `$$element`

**Varies:** `step.variables` · **Value:** `{"ECHOED": "$$element.text"}` · **Effect:** saves the text of the element `find` matched, and the request sends it in its body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren` below the field.
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren` below the field.
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send the text a page shows

. Open `+http://localhost:8092/type-echo.html+`.
. Type `+Wren+` in the field.
. Check that the page shows `+Wren+` below the field.
. Send the text in a `+POST+` request to `+http://localhost:8093/api/names+`. The API returns it.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send the text a page shows</title></head>
<body>
<h1>Send the text a page shows</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.</li>
  <li>Type <code>Wren</code> in the field.</li>
  <li>Check that the page shows <code>Wren</code> below the field.</li>
  <li>Send the text in a <code>POST</code> request to <code>http://localhost:8093/api/names</code>. The API returns it.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send the text a page shows
==========================

#. Open ``http://localhost:8092/type-echo.html``.

#. Type ``Wren`` in the field.

#. Check that the page shows ``Wren`` below the field.

#. Send the text in a ``POST`` request to ``http://localhost:8093/api/names``. The API returns it.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-element">
  <title>Send the text a page shows</title>
  <taskbody>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph> below the field.</cmd></step>
      <step><cmd>Send the text in a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/names</codeph>. The API returns it.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-variables-element","detectSteps":true} -->

# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren` below the field.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} -->
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
   <!-- step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-variables-element","detectSteps":true} */}

# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren` below the field.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} */}
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
   {/* step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send the text a page shows

// (test {"testId":"data-variables-element","detectSteps":true})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+` below the field.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}})
. Send the text in a `+POST+` request to `+http://localhost:8093/api/names+`. The API returns it.
+
// (step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send the text a page shows</title></head>
<body>
<!-- test {"testId":"data-variables-element","detectSteps":true} -->
<h1>Send the text a page shows</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code> below the field.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} --></li>
  <li>Send the text in a <code>POST</code> request to <code>http://localhost:8093/api/names</code>. The API returns it.
    <!-- step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send the text a page shows
==========================

.. test {"testId":"data-variables-element","detectSteps":true}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren`` below the field.

   .. step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}}

#. Send the text in a ``POST`` request to ``http://localhost:8093/api/names``. The API returns it.

   .. step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-element">
  <title>Send the text a page shows</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-element","detectSteps":true}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph> below the field.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}}'/></info></step>
      <step><cmd>Send the text in a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/names</codeph>. The API returns it.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-variables-element","detectSteps":false} -->

# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren` below the field.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} -->
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
   <!-- step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-variables-element","detectSteps":false} */}

# Send the text a page shows

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren` below the field.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} */}
4. Send the text in a `POST` request to `http://localhost:8093/api/names`. The API returns it.
   {/* step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send the text a page shows

// (test {"testId":"data-variables-element","detectSteps":false})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+` below the field.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}})
. Send the text in a `+POST+` request to `+http://localhost:8093/api/names+`. The API returns it.
+
// (step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send the text a page shows</title></head>
<body>
<!-- test {"testId":"data-variables-element","detectSteps":false} -->
<h1>Send the text a page shows</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code> below the field.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}} --></li>
  <li>Send the text in a <code>POST</code> request to <code>http://localhost:8093/api/names</code>. The API returns it.
    <!-- step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send the text a page shows
==========================

.. test {"testId":"data-variables-element","detectSteps":false}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren`` below the field.

   .. step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}}

#. Send the text in a ``POST`` request to ``http://localhost:8093/api/names``. The API returns it.

   .. step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-element">
  <title>Send the text a page shows</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-element","detectSteps":false}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph> below the field.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"},"variables":{"ECHOED":"$$element.text"}}'/></info></step>
      <step><cmd>Send the text in a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/names</codeph>. The API returns it.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/names","method":"post","request":{"body":{"name":"$ECHOED"}},"response":{"body":{"name":"Wren"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-element",
      "steps": [
        {
          "goTo": "http://localhost:8092/type-echo.html"
        },
        {
          "type": {
            "keys": "Wren",
            "selector": "#type-input"
          }
        },
        {
          "find": {
            "selector": "#echo",
            "elementText": "Wren"
          },
          "variables": {
            "ECHOED": "$$element.text"
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/names",
            "method": "post",
            "request": {
              "body": {
                "name": "$ECHOED"
              }
            },
            "response": {
              "body": {
                "name": "Wren"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-element
    steps:
      - goTo: http://localhost:8092/type-echo.html
      - type:
          keys: Wren
          selector: "#type-input"
      - find:
          selector: "#echo"
          elementText: Wren
        variables:
          ECHOED: $$element.text
      - httpRequest:
          url: http://localhost:8093/api/names
          method: post
          request:
            body:
              name: $ECHOED
          response:
            body:
              name: Wren
```

### `extract()`

**Varies:** `step.variables` · **Value:** `{"NODE_MAJOR": "extract($$stdio.stdout, \"v([0-9]+)\")"}` · **Effect:** saves the first group in the regular expression, the major version number.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save the Node.js major version

. Print the Node.js version:
+
[source,shell]
----
node --version
----
. Check that the major version is a number:
+
[source,shell]
----
node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js major version</title></head>
<body>
<h1>Save the Node.js major version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre></li>
  <li>Check that the major version is a number:
    <pre><code class="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save the Node.js major version
==============================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

#. Check that the major version is a number:

   .. code-block:: shell

      node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-extract">
  <title>Save the Node.js major version</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock></info></step>
      <step><cmd>Check that the major version is a number:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-variables-extract","detectSteps":true} -->

# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} -->
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
   <!-- step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-variables-extract","detectSteps":true} */}

# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} */}
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
   {/* step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save the Node.js major version

// (test {"testId":"data-variables-extract","detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}})
. Check that the major version is a number:
+
[source,shell]
----
node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
----
+
// (step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js major version</title></head>
<body>
<!-- test {"testId":"data-variables-extract","detectSteps":true} -->
<h1>Save the Node.js major version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} --></li>
  <li>Check that the major version is a number:
    <pre><code class="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</code></pre>
    <!-- step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save the Node.js major version
==============================

.. test {"testId":"data-variables-extract","detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}

#. Check that the major version is a number:

   .. code-block:: shell

      node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"

   .. step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-extract">
  <title>Save the Node.js major version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-extract","detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}'/></info></step>
      <step><cmd>Check that the major version is a number:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</codeblock>
          <data name="doc-detective" value='step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-variables-extract","detectSteps":false} -->

# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} -->
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
   <!-- step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-variables-extract","detectSteps":false} */}

# Save the Node.js major version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} */}
2. Check that the major version is a number:

   ```shell
   node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
   ```
   {/* step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save the Node.js major version

// (test {"testId":"data-variables-extract","detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}})
. Check that the major version is a number:
+
[source,shell]
----
node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"
----
+
// (step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save the Node.js major version</title></head>
<body>
<!-- test {"testId":"data-variables-extract","detectSteps":false} -->
<h1>Save the Node.js major version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}} --></li>
  <li>Check that the major version is a number:
    <pre><code class="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</code></pre>
    <!-- step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save the Node.js major version
==============================

.. test {"testId":"data-variables-extract","detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}

#. Check that the major version is a number:

   .. code-block:: shell

      node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"

   .. step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-extract">
  <title>Save the Node.js major version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-extract","detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","variables":{"NODE_MAJOR":"extract($$stdio.stdout, \"v([0-9]+)\")"}}'/></info></step>
      <step><cmd>Check that the major version is a number:</cmd>
        <info><codeblock outputclass="language-shell">node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"</codeblock>
          <data name="doc-detective" value='step {"runShell":"node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-extract",
      "steps": [
        {
          "runShell": "node --version",
          "variables": {
            "NODE_MAJOR": "extract($$stdio.stdout, \"v([0-9]+)\")"
          }
        },
        {
          "runShell": "node -e \"process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)\""
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-extract
    steps:
      - runShell: node --version
        variables:
          NODE_MAJOR: extract($$stdio.stdout, "v([0-9]+)")
      - runShell: 'node -e "process.exit(/^[0-9]+$/.test(process.env.NODE_MAJOR) ? 0 : 1)"'
```

### `jq()`

**Varies:** `step.variables` · **Value:** `{"ITEM_COUNT": "jq($$response.body, \".items | length\")"}` · **Effect:** saves the result of a jq query on the response body, the number of items.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Count the items in a cart

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
. Send the count in a `+GET+` request to `+http://localhost:8092/api/carts?count=<count>+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Count the items in a cart</title></head>
<body>
<h1>Count the items in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre></li>
  <li>Send the count in a <code>GET</code> request to <code>http://localhost:8092/api/carts?count=&lt;count&gt;</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Count the items in a cart
=========================

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

#. Send the count in a ``GET`` request to ``http://localhost:8092/api/carts?count=<count>``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-jq">
  <title>Count the items in a cart</title>
  <taskbody>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock></info></step>
      <step><cmd>Send the count in a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/carts?count=&lt;count&gt;</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-variables-jq","detectSteps":true} -->

# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} -->
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-variables-jq","detectSteps":true} */}

# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} */}
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Count the items in a cart

// (test {"testId":"data-variables-jq","detectSteps":true})

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}})
. Send the count in a `+GET+` request to `+http://localhost:8092/api/carts?count=<count>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Count the items in a cart</title></head>
<body>
<!-- test {"testId":"data-variables-jq","detectSteps":true} -->
<h1>Count the items in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} --></li>
  <li>Send the count in a <code>GET</code> request to <code>http://localhost:8092/api/carts?count=&lt;count&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Count the items in a cart
=========================

.. test {"testId":"data-variables-jq","detectSteps":true}

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}}

#. Send the count in a ``GET`` request to ``http://localhost:8092/api/carts?count=<count>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-jq">
  <title>Count the items in a cart</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-jq","detectSteps":true}'/>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}}'/></info></step>
      <step><cmd>Send the count in a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/carts?count=&lt;count&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-variables-jq","detectSteps":false} -->

# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} -->
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-variables-jq","detectSteps":false} */}

# Count the items in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} */}
2. Send the count in a `GET` request to `http://localhost:8092/api/carts?count=<count>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Count the items in a cart

// (test {"testId":"data-variables-jq","detectSteps":false})

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}})
. Send the count in a `+GET+` request to `+http://localhost:8092/api/carts?count=<count>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Count the items in a cart</title></head>
<body>
<!-- test {"testId":"data-variables-jq","detectSteps":false} -->
<h1>Count the items in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}} --></li>
  <li>Send the count in a <code>GET</code> request to <code>http://localhost:8092/api/carts?count=&lt;count&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Count the items in a cart
=========================

.. test {"testId":"data-variables-jq","detectSteps":false}

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}}

#. Send the count in a ``GET`` request to ``http://localhost:8092/api/carts?count=<count>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-jq">
  <title>Count the items in a cart</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-jq","detectSteps":false}'/>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"ITEM_COUNT":"jq($$response.body, \".items | length\")"}}'/></info></step>
      <step><cmd>Send the count in a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/carts?count=&lt;count&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts?count=$ITEM_COUNT","method":"get","response":{"body":{"count":"2"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-jq",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/carts",
            "method": "post",
            "request": {
              "body": {
                "items": [
                  {
                    "sku": "A1",
                    "qty": 2
                  },
                  {
                    "sku": "B2",
                    "qty": 1
                  }
                ]
              }
            }
          },
          "variables": {
            "ITEM_COUNT": "jq($$response.body, \".items | length\")"
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/carts?count=$ITEM_COUNT",
            "method": "get",
            "response": {
              "body": {
                "count": "2"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-jq
    steps:
      - httpRequest:
          url: http://localhost:8092/api/carts
          method: post
          request:
            body:
              items:
                - sku: A1
                  qty: 2
                - sku: B2
                  qty: 1
        variables:
          ITEM_COUNT: jq($$response.body, ".items | length")
      - httpRequest:
          url: http://localhost:8092/api/carts?count=$ITEM_COUNT
          method: get
          response:
            body:
              count: "2"
```

### Array index

**Varies:** `step.variables` · **Value:** `{"FIRST_SKU": "$$response.body.items[0].sku"}` · **Effect:** `[0]` picks the first item of an array in the response body.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Look up the first item in a cart

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
. Look up the first item. Send a `+GET+` request to `+http://localhost:8092/api/products?sku=<sku>+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Look up the first item in a cart</title></head>
<body>
<h1>Look up the first item in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre></li>
  <li>Look up the first item. Send a <code>GET</code> request to <code>http://localhost:8092/api/products?sku=&lt;sku&gt;</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Look up the first item in a cart
================================

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

#. Look up the first item. Send a ``GET`` request to ``http://localhost:8092/api/products?sku=<sku>``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-array-index">
  <title>Look up the first item in a cart</title>
  <taskbody>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock></info></step>
      <step><cmd>Look up the first item. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products?sku=&lt;sku&gt;</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-variables-array-index","detectSteps":true} -->

# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} -->
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-variables-array-index","detectSteps":true} */}

# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} */}
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Look up the first item in a cart

// (test {"testId":"data-variables-array-index","detectSteps":true})

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}})
. Look up the first item. Send a `+GET+` request to `+http://localhost:8092/api/products?sku=<sku>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Look up the first item in a cart</title></head>
<body>
<!-- test {"testId":"data-variables-array-index","detectSteps":true} -->
<h1>Look up the first item in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} --></li>
  <li>Look up the first item. Send a <code>GET</code> request to <code>http://localhost:8092/api/products?sku=&lt;sku&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Look up the first item in a cart
================================

.. test {"testId":"data-variables-array-index","detectSteps":true}

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}}

#. Look up the first item. Send a ``GET`` request to ``http://localhost:8092/api/products?sku=<sku>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-array-index">
  <title>Look up the first item in a cart</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-array-index","detectSteps":true}'/>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}}'/></info></step>
      <step><cmd>Look up the first item. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products?sku=&lt;sku&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-variables-array-index","detectSteps":false} -->

# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} -->
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-variables-array-index","detectSteps":false} */}

# Look up the first item in a cart

1. Create a cart. Send a `POST` request to `http://localhost:8092/api/carts` with this body:

   ```json
   {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} */}
2. Look up the first item. Send a `GET` request to `http://localhost:8092/api/products?sku=<sku>`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Look up the first item in a cart

// (test {"testId":"data-variables-array-index","detectSteps":false})

. Create a cart. Send a `+POST+` request to `+http://localhost:8092/api/carts+` with this body:
+
[source,json]
----
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}})
. Look up the first item. Send a `+GET+` request to `+http://localhost:8092/api/products?sku=<sku>+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Look up the first item in a cart</title></head>
<body>
<!-- test {"testId":"data-variables-array-index","detectSteps":false} -->
<h1>Look up the first item in a cart</h1>
<ol>
  <li>Create a cart. Send a <code>POST</code> request to <code>http://localhost:8092/api/carts</code> with this body:
    <pre><code class="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}} --></li>
  <li>Look up the first item. Send a <code>GET</code> request to <code>http://localhost:8092/api/products?sku=&lt;sku&gt;</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Look up the first item in a cart
================================

.. test {"testId":"data-variables-array-index","detectSteps":false}

#. Create a cart. Send a ``POST`` request to ``http://localhost:8092/api/carts`` with this body:

   .. code-block:: json

      {"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}}

#. Look up the first item. Send a ``GET`` request to ``http://localhost:8092/api/products?sku=<sku>``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-variables-array-index">
  <title>Look up the first item in a cart</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-variables-array-index","detectSteps":false}'/>
    <steps>
      <step><cmd>Create a cart. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/carts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/carts","method":"post","request":{"body":{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}]}}},"variables":{"FIRST_SKU":"$$response.body.items[0].sku"}}'/></info></step>
      <step><cmd>Look up the first item. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products?sku=&lt;sku&gt;</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/products?sku=$FIRST_SKU","method":"get","response":{"body":{"sku":"A1"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-variables-array-index",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/carts",
            "method": "post",
            "request": {
              "body": {
                "items": [
                  {
                    "sku": "A1",
                    "qty": 2
                  },
                  {
                    "sku": "B2",
                    "qty": 1
                  }
                ]
              }
            }
          },
          "variables": {
            "FIRST_SKU": "$$response.body.items[0].sku"
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/products?sku=$FIRST_SKU",
            "method": "get",
            "response": {
              "body": {
                "sku": "A1"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-variables-array-index
    steps:
      - httpRequest:
          url: http://localhost:8092/api/carts
          method: post
          request:
            body:
              items:
                - sku: A1
                  qty: 2
                - sku: B2
                  qty: 1
        variables:
          FIRST_SKU: $$response.body.items[0].sku
      - httpRequest:
          url: http://localhost:8092/api/products?sku=$FIRST_SKU
          method: get
          response:
            body:
              sku: A1
```

## `$VAR` substitution permutations

### In `httpRequest.url`

**Varies:** `httpRequest.url` · **Value:** `"$SHOP_URL/products"` · **Effect:** doc Detective replaces `$SHOP_URL` in the URL before it sends the request.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# List products from a configured URL

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# List products from a configured URL

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= List products from a configured URL

. Load the variables in `+shop.env+`.
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products from a configured URL</title></head>
<body>
<h1>List products from a configured URL</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
List products from a configured URL
===================================

#. Load the variables in ``shop.env``.

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-url">
  <title>List products from a configured URL</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-substitution-url","detectSteps":true} -->

# List products from a configured URL

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-substitution-url","detectSteps":true} */}

# List products from a configured URL

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= List products from a configured URL

// (test {"testId":"data-substitution-url","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products from a configured URL</title></head>
<body>
<!-- test {"testId":"data-substitution-url","detectSteps":true} -->
<h1>List products from a configured URL</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
List products from a configured URL
===================================

.. test {"testId":"data-substitution-url","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-url">
  <title>List products from a configured URL</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-url","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-substitution-url","detectSteps":false} -->

# List products from a configured URL

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-substitution-url","detectSteps":false} */}

# List products from a configured URL

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= List products from a configured URL

// (test {"testId":"data-substitution-url","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products from a configured URL</title></head>
<body>
<!-- test {"testId":"data-substitution-url","detectSteps":false} -->
<h1>List products from a configured URL</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
List products from a configured URL
===================================

.. test {"testId":"data-substitution-url","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-url">
  <title>List products from a configured URL</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-url","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-substitution-url",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "$SHOP_URL/products",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-substitution-url
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: $SHOP_URL/products
          method: get
```

### In `httpRequest.request.headers`

**Varies:** `httpRequest.request.headers` · **Value:** `{"X-Test": "$SHOP_CLIENT"}` · **Effect:** the header carries the variable's value, and the echo API returns it in `x-echo-test`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send a client name in a header

1. Load the variables in `shop.env`.
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send a client name in a header

1. Load the variables in `shop.env`.
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a client name in a header

. Load the variables in `+shop.env+`.
. Send a `+GET+` request to `+http://localhost:8092/api/products+` with the header `+X-Test: $SHOP_CLIENT+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a header</title></head>
<body>
<h1>Send a client name in a header</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>Send a <code>GET</code> request to <code>http://localhost:8092/api/products</code> with the header <code>X-Test: $SHOP_CLIENT</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a client name in a header
==============================

#. Load the variables in ``shop.env``.

#. Send a ``GET`` request to ``http://localhost:8092/api/products`` with the header ``X-Test: $SHOP_CLIENT``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-headers">
  <title>Send a client name in a header</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products</codeph> with the header <codeph>X-Test: $SHOP_CLIENT</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-substitution-headers","detectSteps":true} -->

# Send a client name in a header

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-substitution-headers","detectSteps":true} */}

# Send a client name in a header

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a client name in a header

// (test {"testId":"data-substitution-headers","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Send a `+GET+` request to `+http://localhost:8092/api/products+` with the header `+X-Test: $SHOP_CLIENT+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a header</title></head>
<body>
<!-- test {"testId":"data-substitution-headers","detectSteps":true} -->
<h1>Send a client name in a header</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Send a <code>GET</code> request to <code>http://localhost:8092/api/products</code> with the header <code>X-Test: $SHOP_CLIENT</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a client name in a header
==============================

.. test {"testId":"data-substitution-headers","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Send a ``GET`` request to ``http://localhost:8092/api/products`` with the header ``X-Test: $SHOP_CLIENT``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-headers">
  <title>Send a client name in a header</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-headers","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products</codeph> with the header <codeph>X-Test: $SHOP_CLIENT</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-substitution-headers","detectSteps":false} -->

# Send a client name in a header

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-substitution-headers","detectSteps":false} */}

# Send a client name in a header

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Send a `GET` request to `http://localhost:8092/api/products` with the header `X-Test: $SHOP_CLIENT`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a client name in a header

// (test {"testId":"data-substitution-headers","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Send a `+GET+` request to `+http://localhost:8092/api/products+` with the header `+X-Test: $SHOP_CLIENT+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a header</title></head>
<body>
<!-- test {"testId":"data-substitution-headers","detectSteps":false} -->
<h1>Send a client name in a header</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Send a <code>GET</code> request to <code>http://localhost:8092/api/products</code> with the header <code>X-Test: $SHOP_CLIENT</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a client name in a header
==============================

.. test {"testId":"data-substitution-headers","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Send a ``GET`` request to ``http://localhost:8092/api/products`` with the header ``X-Test: $SHOP_CLIENT``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-headers">
  <title>Send a client name in a header</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-headers","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/products</codeph> with the header <codeph>X-Test: $SHOP_CLIENT</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/products","method":"get","request":{"headers":{"X-Test":"$SHOP_CLIENT"}},"response":{"headers":{"x-echo-test":"docs"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-substitution-headers",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/products",
            "method": "get",
            "request": {
              "headers": {
                "X-Test": "$SHOP_CLIENT"
              }
            },
            "response": {
              "headers": {
                "x-echo-test": "docs"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-substitution-headers
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: http://localhost:8092/api/products
          method: get
          request:
            headers:
              X-Test: $SHOP_CLIENT
          response:
            headers:
              x-echo-test: docs
```

### In `httpRequest.request.body`

**Varies:** `httpRequest.request.body` · **Value:** `{"client": "$SHOP_CLIENT"}` · **Effect:** the body carries the variable's value, and the echo API returns it.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send a client name in a request body

1. Load the variables in `shop.env`.
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send a client name in a request body

1. Load the variables in `shop.env`.
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a client name in a request body

. Load the variables in `+shop.env+`.
. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with the body `+{"client": "$SHOP_CLIENT"}+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a request body</title></head>
<body>
<h1>Send a client name in a request body</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with the body <code>{"client": "$SHOP_CLIENT"}</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a client name in a request body
====================================

#. Load the variables in ``shop.env``.

#. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with the body ``{"client": "$SHOP_CLIENT"}``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-body">
  <title>Send a client name in a request body</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with the body <codeph>{"client": "$SHOP_CLIENT"}</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-substitution-body","detectSteps":true} -->

# Send a client name in a request body

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-substitution-body","detectSteps":true} */}

# Send a client name in a request body

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a client name in a request body

// (test {"testId":"data-substitution-body","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with the body `+{"client": "$SHOP_CLIENT"}+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a request body</title></head>
<body>
<!-- test {"testId":"data-substitution-body","detectSteps":true} -->
<h1>Send a client name in a request body</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with the body <code>{"client": "$SHOP_CLIENT"}</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a client name in a request body
====================================

.. test {"testId":"data-substitution-body","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with the body ``{"client": "$SHOP_CLIENT"}``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-body">
  <title>Send a client name in a request body</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-body","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with the body <codeph>{"client": "$SHOP_CLIENT"}</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-substitution-body","detectSteps":false} -->

# Send a client name in a request body

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-substitution-body","detectSteps":false} */}

# Send a client name in a request body

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Send a `POST` request to `http://localhost:8092/api/orders` with the body `{"client": "$SHOP_CLIENT"}`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a client name in a request body

// (test {"testId":"data-substitution-body","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Send a `+POST+` request to `+http://localhost:8092/api/orders+` with the body `+{"client": "$SHOP_CLIENT"}+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a client name in a request body</title></head>
<body>
<!-- test {"testId":"data-substitution-body","detectSteps":false} -->
<h1>Send a client name in a request body</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Send a <code>POST</code> request to <code>http://localhost:8092/api/orders</code> with the body <code>{"client": "$SHOP_CLIENT"}</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a client name in a request body
====================================

.. test {"testId":"data-substitution-body","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Send a ``POST`` request to ``http://localhost:8092/api/orders`` with the body ``{"client": "$SHOP_CLIENT"}``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-body">
  <title>Send a client name in a request body</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-body","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/orders</codeph> with the body <codeph>{"client": "$SHOP_CLIENT"}</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/orders","method":"post","request":{"body":{"client":"$SHOP_CLIENT"}},"response":{"body":{"client":"docs"}}}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-substitution-body",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/orders",
            "method": "post",
            "request": {
              "body": {
                "client": "$SHOP_CLIENT"
              }
            },
            "response": {
              "body": {
                "client": "docs"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-substitution-body
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: http://localhost:8092/api/orders
          method: post
          request:
            body:
              client: $SHOP_CLIENT
          response:
            body:
              client: docs
```

### In `type.selector` and `find.selector`

**Varies:** `type.selector` and `find.selector` · **Value:** `"$INPUT_SELECTOR"` · **Effect:** selectors take variables too, so one file can name the elements for several tests.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Type into a field named by a variable

1. Load the variables in `shop.env`.
2. Open `http://localhost:8092/type-echo.html`.
3. Type `Wren` in the field.
4. Check that the page shows `Wren`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Type into a field named by a variable

1. Load the variables in `shop.env`.
2. Open `http://localhost:8092/type-echo.html`.
3. Type `Wren` in the field.
4. Check that the page shows `Wren`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Type into a field named by a variable

. Load the variables in `+shop.env+`.
. Open `+http://localhost:8092/type-echo.html+`.
. Type `+Wren+` in the field.
. Check that the page shows `+Wren+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Type into a field named by a variable</title></head>
<body>
<h1>Type into a field named by a variable</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.</li>
  <li>Type <code>Wren</code> in the field.</li>
  <li>Check that the page shows <code>Wren</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Type into a field named by a variable
=====================================

#. Load the variables in ``shop.env``.

#. Open ``http://localhost:8092/type-echo.html``.

#. Type ``Wren`` in the field.

#. Check that the page shows ``Wren``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-selector">
  <title>Type into a field named by a variable</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-substitution-selector","detectSteps":true} -->

# Type into a field named by a variable

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
3. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} -->
4. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-substitution-selector","detectSteps":true} */}

# Type into a field named by a variable

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
3. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} */}
4. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Type into a field named by a variable

// (test {"testId":"data-substitution-selector","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Type into a field named by a variable</title></head>
<body>
<!-- test {"testId":"data-substitution-selector","detectSteps":true} -->
<h1>Type into a field named by a variable</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Type into a field named by a variable
=====================================

.. test {"testId":"data-substitution-selector","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-selector">
  <title>Type into a field named by a variable</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-selector","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-substitution-selector","detectSteps":false} -->

# Type into a field named by a variable

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
3. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} -->
4. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-substitution-selector","detectSteps":false} */}

# Type into a field named by a variable

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
3. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} */}
4. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Type into a field named by a variable

// (test {"testId":"data-substitution-selector","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Type into a field named by a variable</title></head>
<body>
<!-- test {"testId":"data-substitution-selector","detectSteps":false} -->
<h1>Type into a field named by a variable</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Type into a field named by a variable
=====================================

.. test {"testId":"data-substitution-selector","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-substitution-selector">
  <title>Type into a field named by a variable</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-substitution-selector","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"$INPUT_SELECTOR"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"$ECHO_SELECTOR","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-substitution-selector",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "goTo": "http://localhost:8092/type-echo.html"
        },
        {
          "type": {
            "keys": "Wren",
            "selector": "$INPUT_SELECTOR"
          }
        },
        {
          "find": {
            "selector": "$ECHO_SELECTOR",
            "elementText": "Wren"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-substitution-selector
    steps:
      - loadVariables: shop.env
      - goTo: http://localhost:8092/type-echo.html
      - type:
          keys: Wren
          selector: $INPUT_SELECTOR
      - find:
          selector: $ECHO_SELECTOR
          elementText: Wren
```

## `publicVariables` permutations

### Test, exact name

**Varies:** `test.publicVariables` · **Value:** `["SHOP_URL"]` · **Effect:** reports show the value of `SHOP_URL`, and mask `SHOP_CLIENT` and the selectors as `***NAME***`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= List products and show the URL in reports

. Load the variables in `+shop.env+`.
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
List products and show the URL in reports
=========================================

#. Load the variables in ``shop.env``.

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-exact">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-exact">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-exact">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-test-exact","publicVariables":["SHOP_URL"],"detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-publicvariables-test-exact",
      "publicVariables": [
        "SHOP_URL"
      ],
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "$SHOP_URL/products",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-publicvariables-test-exact
    publicVariables:
      - SHOP_URL
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: $SHOP_URL/products
          method: get
```

### Test, wildcard

**Varies:** `test.publicVariables` · **Value:** `["SHOP_*"]` · **Effect:** `*` matches any characters, so reports show `SHOP_URL` and `SHOP_CLIENT`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= List products and show the URL in reports

. Load the variables in `+shop.env+`.
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
List products and show the URL in reports
=========================================

#. Load the variables in ``shop.env``.

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-wildcard">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-wildcard">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-test-wildcard">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-test-wildcard","publicVariables":["SHOP_*"],"detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-publicvariables-test-wildcard",
      "publicVariables": [
        "SHOP_*"
      ],
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "$SHOP_URL/products",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-publicvariables-test-wildcard
    publicVariables:
      - SHOP_*
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: $SHOP_URL/products
          method: get
```

### Spec

**Varies:** `spec.publicVariables` · **Value:** `["SHOP_URL"]` · **Effect:** only the standalone spec can set it. A name listed on any spec is public for the whole run.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= List products and show the URL in reports

. Load the variables in `+shop.env+`.
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
List products and show the URL in reports
=========================================

#. Load the variables in ``shop.env``.

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-spec">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-publicvariables-spec","detectSteps":true} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-publicvariables-spec","detectSteps":true} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-spec","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-spec","detectSteps":true} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-spec","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-spec">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-spec","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-publicvariables-spec","detectSteps":false} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-publicvariables-spec","detectSteps":false} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-spec","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-spec","detectSteps":false} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-spec","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-spec">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-spec","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "publicVariables": [
    "SHOP_URL"
  ],
  "tests": [
    {
      "testId": "data-publicvariables-spec",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "$SHOP_URL/products",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
publicVariables:
  - SHOP_URL
tests:
  - testId: data-publicvariables-spec
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: $SHOP_URL/products
          method: get
```

### In the config file

**Varies:** `config.publicVariables` · **Value:** `["SHOP_URL"]` · **Effect:** the example's `doc-detective.json` lists the name, so every file in the run shows it.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# List products and show the URL in reports

1. Load the variables in `shop.env`.
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= List products and show the URL in reports

. Load the variables in `+shop.env+`.
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.</li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
List products and show the URL in reports
=========================================

#. Load the variables in ``shop.env``.

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-config">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-publicvariables-config","detectSteps":true} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-publicvariables-config","detectSteps":true} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-config","detectSteps":true})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-config","detectSteps":true} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-config","detectSteps":true}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-config">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-config","detectSteps":true}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-publicvariables-config","detectSteps":false} -->

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   <!-- step {"loadVariables":"shop.env"} -->
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-publicvariables-config","detectSteps":false} */}

# List products and show the URL in reports

1. Load the variables in `shop.env`.
   {/* step {"loadVariables":"shop.env"} */}
2. List the products. Send a `GET` request to `$SHOP_URL/products`.
   {/* step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= List products and show the URL in reports

// (test {"testId":"data-publicvariables-config","detectSteps":false})

. Load the variables in `+shop.env+`.
+
// (step {"loadVariables":"shop.env"})
. List the products. Send a `+GET+` request to `+$SHOP_URL/products+`.
+
// (step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>List products and show the URL in reports</title></head>
<body>
<!-- test {"testId":"data-publicvariables-config","detectSteps":false} -->
<h1>List products and show the URL in reports</h1>
<ol>
  <li>Load the variables in <code>shop.env</code>.
    <!-- step {"loadVariables":"shop.env"} --></li>
  <li>List the products. Send a <code>GET</code> request to <code>$SHOP_URL/products</code>.
    <!-- step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
List products and show the URL in reports
=========================================

.. test {"testId":"data-publicvariables-config","detectSteps":false}

#. Load the variables in ``shop.env``.

   .. step {"loadVariables":"shop.env"}

#. List the products. Send a ``GET`` request to ``$SHOP_URL/products``.

   .. step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-publicvariables-config">
  <title>List products and show the URL in reports</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-publicvariables-config","detectSteps":false}'/>
    <steps>
      <step><cmd>Load the variables in <codeph>shop.env</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"loadVariables":"shop.env"}'/></info></step>
      <step><cmd>List the products. Send a <codeph>GET</codeph> request to <codeph>$SHOP_URL/products</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"$SHOP_URL/products","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-publicvariables-config",
      "steps": [
        {
          "loadVariables": "shop.env"
        },
        {
          "httpRequest": {
            "url": "$SHOP_URL/products",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-publicvariables-config
    steps:
      - loadVariables: shop.env
      - httpRequest:
          url: $SHOP_URL/products
          method: get
```

## `if` permutations

### Step, string, true

**Varies:** `step.if` · **Value:** `"$$steps.version.outputs.exitCode == 0"` · **Effect:** the condition reads an earlier step's output by its `stepId`. It's true, so the step runs.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Print the npm version after Node.js

. Print the Node.js version:
+
[source,shell]
----
node --version
----
. If that worked, print the npm version:
+
[source,shell]
----
npm --version
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after Node.js</title></head>
<body>
<h1>Print the npm version after Node.js</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre></li>
  <li>If that worked, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Print the npm version after Node.js
===================================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

#. If that worked, print the npm version:

   .. code-block:: shell

      npm --version
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-true">
  <title>Print the npm version after Node.js</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock></info></step>
      <step><cmd>If that worked, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-if-step-string-true","detectSteps":true} -->

# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-if-step-string-true","detectSteps":true} */}

# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Print the npm version after Node.js

// (test {"testId":"data-if-step-string-true","detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that worked, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after Node.js</title></head>
<body>
<!-- test {"testId":"data-if-step-string-true","detectSteps":true} -->
<h1>Print the npm version after Node.js</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that worked, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Print the npm version after Node.js
===================================

.. test {"testId":"data-if-step-string-true","detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that worked, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-true">
  <title>Print the npm version after Node.js</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-string-true","detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that worked, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-if-step-string-true","detectSteps":false} -->

# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-if-step-string-true","detectSteps":false} */}

# Print the npm version after Node.js

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that worked, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Print the npm version after Node.js

// (test {"testId":"data-if-step-string-true","detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that worked, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after Node.js</title></head>
<body>
<!-- test {"testId":"data-if-step-string-true","detectSteps":false} -->
<h1>Print the npm version after Node.js</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that worked, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Print the npm version after Node.js
===================================

.. test {"testId":"data-if-step-string-true","detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that worked, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-true">
  <title>Print the npm version after Node.js</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-string-true","detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that worked, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":"$$steps.version.outputs.exitCode == 0","runShell":"npm --version"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-step-string-true",
      "steps": [
        {
          "runShell": "node --version",
          "stepId": "version"
        },
        {
          "if": "$$steps.version.outputs.exitCode == 0",
          "runShell": "npm --version"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-step-string-true
    steps:
      - runShell: node --version
        stepId: version
      - if: $$steps.version.outputs.exitCode == 0
        runShell: npm --version
```

### Step, string, false

**Varies:** `step.if` · **Value:** `"$$steps.version.outputs.exitCode != 0"` · **Effect:** the condition is false, so Doc Detective skips the step. The test still passes.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Show help only when Node.js fails

. Print the Node.js version:
+
[source,shell]
----
node --version
----
. If that failed, print the help for `+node+`:
+
[source,shell]
----
node --help
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show help only when Node.js fails</title></head>
<body>
<h1>Show help only when Node.js fails</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre></li>
  <li>If that failed, print the help for <code>node</code>:
    <pre><code class="language-shell">node --help</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Show help only when Node.js fails
=================================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

#. If that failed, print the help for ``node``:

   .. code-block:: shell

      node --help
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-false">
  <title>Show help only when Node.js fails</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock></info></step>
      <step><cmd>If that failed, print the help for <codeph>node</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node --help</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-if-step-string-false","detectSteps":true} -->

# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
   <!-- step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-if-step-string-false","detectSteps":true} */}

# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
   {/* step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Show help only when Node.js fails

// (test {"testId":"data-if-step-string-false","detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that failed, print the help for `+node+`:
+
[source,shell]
----
node --help
----
+
// (step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show help only when Node.js fails</title></head>
<body>
<!-- test {"testId":"data-if-step-string-false","detectSteps":true} -->
<h1>Show help only when Node.js fails</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that failed, print the help for <code>node</code>:
    <pre><code class="language-shell">node --help</code></pre>
    <!-- step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Show help only when Node.js fails
=================================

.. test {"testId":"data-if-step-string-false","detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that failed, print the help for ``node``:

   .. code-block:: shell

      node --help

   .. step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-false">
  <title>Show help only when Node.js fails</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-string-false","detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that failed, print the help for <codeph>node</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node --help</codeblock>
          <data name="doc-detective" value='step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-if-step-string-false","detectSteps":false} -->

# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
   <!-- step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-if-step-string-false","detectSteps":false} */}

# Show help only when Node.js fails

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that failed, print the help for `node`:

   ```shell
   node --help
   ```
   {/* step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Show help only when Node.js fails

// (test {"testId":"data-if-step-string-false","detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that failed, print the help for `+node+`:
+
[source,shell]
----
node --help
----
+
// (step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show help only when Node.js fails</title></head>
<body>
<!-- test {"testId":"data-if-step-string-false","detectSteps":false} -->
<h1>Show help only when Node.js fails</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that failed, print the help for <code>node</code>:
    <pre><code class="language-shell">node --help</code></pre>
    <!-- step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Show help only when Node.js fails
=================================

.. test {"testId":"data-if-step-string-false","detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that failed, print the help for ``node``:

   .. code-block:: shell

      node --help

   .. step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-string-false">
  <title>Show help only when Node.js fails</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-string-false","detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that failed, print the help for <codeph>node</codeph>:</cmd>
        <info><codeblock outputclass="language-shell">node --help</codeblock>
          <data name="doc-detective" value='step {"if":"$$steps.version.outputs.exitCode != 0","runShell":"node --help"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-step-string-false",
      "steps": [
        {
          "runShell": "node --version",
          "stepId": "version"
        },
        {
          "if": "$$steps.version.outputs.exitCode != 0",
          "runShell": "node --help"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-step-string-false
    steps:
      - runShell: node --version
        stepId: version
      - if: $$steps.version.outputs.exitCode != 0
        runShell: node --help
```

### Step, array

**Varies:** `step.if` · **Value:** `["$$steps.version.outputs.exitCode == 0", "$$steps.version.outputs.stdio.stdout matches /^v/"]` · **Effect:** every condition in the array must be true for the step to run.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Print the npm version after a valid Node.js version

. Print the Node.js version:
+
[source,shell]
----
node --version
----
. If that printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after a valid Node.js version</title></head>
<body>
<h1>Print the npm version after a valid Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre></li>
  <li>If that printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Print the npm version after a valid Node.js version
===================================================

#. Print the Node.js version:

   .. code-block:: shell

      node --version

#. If that printed a version, print the npm version:

   .. code-block:: shell

      npm --version
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-array">
  <title>Print the npm version after a valid Node.js version</title>
  <taskbody>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock></info></step>
      <step><cmd>If that printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-if-step-array","detectSteps":true} -->

# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-if-step-array","detectSteps":true} */}

# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Print the npm version after a valid Node.js version

// (test {"testId":"data-if-step-array","detectSteps":true})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after a valid Node.js version</title></head>
<body>
<!-- test {"testId":"data-if-step-array","detectSteps":true} -->
<h1>Print the npm version after a valid Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Print the npm version after a valid Node.js version
===================================================

.. test {"testId":"data-if-step-array","detectSteps":true}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that printed a version, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-array">
  <title>Print the npm version after a valid Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-array","detectSteps":true}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-if-step-array","detectSteps":false} -->

# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   <!-- step {"runShell":"node --version","stepId":"version"} -->
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
   <!-- step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-if-step-array","detectSteps":false} */}

# Print the npm version after a valid Node.js version

1. Print the Node.js version:

   ```shell
   node --version
   ```
   {/* step {"runShell":"node --version","stepId":"version"} */}
2. If that printed a version, print the npm version:

   ```shell
   npm --version
   ```
   {/* step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Print the npm version after a valid Node.js version

// (test {"testId":"data-if-step-array","detectSteps":false})

. Print the Node.js version:
+
[source,shell]
----
node --version
----
+
// (step {"runShell":"node --version","stepId":"version"})
. If that printed a version, print the npm version:
+
[source,shell]
----
npm --version
----
+
// (step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print the npm version after a valid Node.js version</title></head>
<body>
<!-- test {"testId":"data-if-step-array","detectSteps":false} -->
<h1>Print the npm version after a valid Node.js version</h1>
<ol>
  <li>Print the Node.js version:
    <pre><code class="language-shell">node --version</code></pre>
    <!-- step {"runShell":"node --version","stepId":"version"} --></li>
  <li>If that printed a version, print the npm version:
    <pre><code class="language-shell">npm --version</code></pre>
    <!-- step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Print the npm version after a valid Node.js version
===================================================

.. test {"testId":"data-if-step-array","detectSteps":false}

#. Print the Node.js version:

   .. code-block:: shell

      node --version

   .. step {"runShell":"node --version","stepId":"version"}

#. If that printed a version, print the npm version:

   .. code-block:: shell

      npm --version

   .. step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-step-array">
  <title>Print the npm version after a valid Node.js version</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-step-array","detectSteps":false}'/>
    <steps>
      <step><cmd>Print the Node.js version:</cmd>
        <info><codeblock outputclass="language-shell">node --version</codeblock>
          <data name="doc-detective" value='step {"runShell":"node --version","stepId":"version"}'/></info></step>
      <step><cmd>If that printed a version, print the npm version:</cmd>
        <info><codeblock outputclass="language-shell">npm --version</codeblock>
          <data name="doc-detective" value='step {"if":["$$steps.version.outputs.exitCode == 0","$$steps.version.outputs.stdio.stdout matches /^v/"],"runShell":"npm --version"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-step-array",
      "steps": [
        {
          "runShell": "node --version",
          "stepId": "version"
        },
        {
          "if": [
            "$$steps.version.outputs.exitCode == 0",
            "$$steps.version.outputs.stdio.stdout matches /^v/"
          ],
          "runShell": "npm --version"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-step-array
    steps:
      - runShell: node --version
        stepId: version
      - if:
          - $$steps.version.outputs.exitCode == 0
          - $$steps.version.outputs.stdio.stdout matches /^v/
        runShell: npm --version
```

### Test, string

**Varies:** `test.if` · **Value:** `"$$platform oneOf [linux, mac, windows]"` · **Effect:** the test runs only when the condition is true. A test condition can read `$$platform`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the API on desktop platforms

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the API on desktop platforms
==================================

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":true}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-string","if":"$$platform oneOf [linux, mac, windows]","detectSteps":false}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-test-string",
      "if": "$$platform oneOf [linux, mac, windows]",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-test-string
    if: $$platform oneOf [linux, mac, windows]
    steps:
      - httpRequest:
          url: http://localhost:8092/api/health
          method: get
```

### Test, array

**Varies:** `test.if` · **Value:** `["$$platform oneOf [linux, mac, windows]"]` · **Effect:** the array form takes one or more conditions, and all must be true.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the API on desktop platforms

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the API on desktop platforms
==================================

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":true}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-array","if":["$$platform oneOf [linux, mac, windows]"],"detectSteps":false}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-test-array",
      "if": [
        "$$platform oneOf [linux, mac, windows]"
      ],
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-test-array
    if:
      - $$platform oneOf [linux, mac, windows]
    steps:
      - httpRequest:
          url: http://localhost:8092/api/health
          method: get
```

### Test, by platform

**Varies:** `test.if` · **Value:** `"$$platform == windows"` · **Effect:** the test runs on Windows and is skipped on macOS and Linux.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Find Node.js on Windows

. On Windows, find the Node.js executable:
+
[source,shell]
----
where node
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Find Node.js on Windows</title></head>
<body>
<h1>Find Node.js on Windows</h1>
<ol>
  <li>On Windows, find the Node.js executable:
    <pre><code class="language-shell">where node</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Find Node.js on Windows
=======================

#. On Windows, find the Node.js executable:

   .. code-block:: shell

      where node
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-platform">
  <title>Find Node.js on Windows</title>
  <taskbody>
    <steps>
      <step><cmd>On Windows, find the Node.js executable:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true} -->

# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
   <!-- step {"runShell":"where node"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true} */}

# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
   {/* step {"runShell":"where node"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Find Node.js on Windows

// (test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true})

. On Windows, find the Node.js executable:
+
[source,shell]
----
where node
----
+
// (step {"runShell":"where node"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Find Node.js on Windows</title></head>
<body>
<!-- test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true} -->
<h1>Find Node.js on Windows</h1>
<ol>
  <li>On Windows, find the Node.js executable:
    <pre><code class="language-shell">where node</code></pre>
    <!-- step {"runShell":"where node"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Find Node.js on Windows
=======================

.. test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true}

#. On Windows, find the Node.js executable:

   .. code-block:: shell

      where node

   .. step {"runShell":"where node"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-platform">
  <title>Find Node.js on Windows</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":true}'/>
    <steps>
      <step><cmd>On Windows, find the Node.js executable:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock>
          <data name="doc-detective" value='step {"runShell":"where node"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false} -->

# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
   <!-- step {"runShell":"where node"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false} */}

# Find Node.js on Windows

1. On Windows, find the Node.js executable:

   ```shell
   where node
   ```
   {/* step {"runShell":"where node"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Find Node.js on Windows

// (test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false})

. On Windows, find the Node.js executable:
+
[source,shell]
----
where node
----
+
// (step {"runShell":"where node"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Find Node.js on Windows</title></head>
<body>
<!-- test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false} -->
<h1>Find Node.js on Windows</h1>
<ol>
  <li>On Windows, find the Node.js executable:
    <pre><code class="language-shell">where node</code></pre>
    <!-- step {"runShell":"where node"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Find Node.js on Windows
=======================

.. test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false}

#. On Windows, find the Node.js executable:

   .. code-block:: shell

      where node

   .. step {"runShell":"where node"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-test-platform">
  <title>Find Node.js on Windows</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-test-platform","if":"$$platform == windows","detectSteps":false}'/>
    <steps>
      <step><cmd>On Windows, find the Node.js executable:</cmd>
        <info><codeblock outputclass="language-shell">where node</codeblock>
          <data name="doc-detective" value='step {"runShell":"where node"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-if-test-platform",
      "if": "$$platform == windows",
      "steps": [
        {
          "runShell": "where node"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-if-test-platform
    if: $$platform == windows
    steps:
      - runShell: where node
```

### Spec, string

**Varies:** `spec.if` · **Value:** `"$$platform oneOf [linux, mac, windows]"` · **Effect:** only the standalone spec can set it. When it's false, Doc Detective skips the whole spec.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the API on desktop platforms

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the API on desktop platforms
==================================

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-if-spec-string","detectSteps":true} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-if-spec-string","detectSteps":true} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-spec-string","detectSteps":true})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-spec-string","detectSteps":true} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-spec-string","detectSteps":true}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-spec-string","detectSteps":true}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-if-spec-string","detectSteps":false} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-if-spec-string","detectSteps":false} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-spec-string","detectSteps":false})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-spec-string","detectSteps":false} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-spec-string","detectSteps":false}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-string">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-spec-string","detectSteps":false}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "if": "$$platform oneOf [linux, mac, windows]",
  "tests": [
    {
      "testId": "data-if-spec-string",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
if: $$platform oneOf [linux, mac, windows]
tests:
  - testId: data-if-spec-string
    steps:
      - httpRequest:
          url: http://localhost:8092/api/health
          method: get
```

### Spec, array

**Varies:** `spec.if` · **Value:** `["$$platform oneOf [linux, mac, windows]"]` · **Effect:** only the standalone spec can set it. Every condition must be true for the spec to run.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the API on desktop platforms

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the API on desktop platforms
==================================

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-if-spec-array","detectSteps":true} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-if-spec-array","detectSteps":true} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-spec-array","detectSteps":true})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-spec-array","detectSteps":true} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-spec-array","detectSteps":true}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-spec-array","detectSteps":true}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-if-spec-array","detectSteps":false} -->

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-if-spec-array","detectSteps":false} */}

# Check the API on desktop platforms

1. Check the API. Send a `GET` request to `http://localhost:8092/api/health`.
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the API on desktop platforms

// (test {"testId":"data-if-spec-array","detectSteps":false})

. Check the API. Send a `+GET+` request to `+http://localhost:8092/api/health+`.
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the API on desktop platforms</title></head>
<body>
<!-- test {"testId":"data-if-spec-array","detectSteps":false} -->
<h1>Check the API on desktop platforms</h1>
<ol>
  <li>Check the API. Send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the API on desktop platforms
==================================

.. test {"testId":"data-if-spec-array","detectSteps":false}

#. Check the API. Send a ``GET`` request to ``http://localhost:8092/api/health``.

   .. step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-if-spec-array">
  <title>Check the API on desktop platforms</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-if-spec-array","detectSteps":false}'/>
    <steps>
      <step><cmd>Check the API. Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/health","method":"get"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "if": [
    "$$platform oneOf [linux, mac, windows]"
  ],
  "tests": [
    {
      "testId": "data-if-spec-array",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/health",
            "method": "get"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
if:
  - $$platform oneOf [linux, mac, windows]
tests:
  - testId: data-if-spec-array
    steps:
      - httpRequest:
          url: http://localhost:8092/api/health
          method: get
```

## `assertions` permutations

### String

**Varies:** `step.assertions` · **Value:** `"$$outputs.response.statusCode == 200"` · **Effect:** one custom check runs after the request's own checks, and the step fails if it's false.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create an account and check the status

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the status</title></head>
<body>
<h1>Create an account and check the status</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create an account and check the status
======================================

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-string">
  <title>Create an account and check the status</title>
  <taskbody>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-assertions-string","detectSteps":true} -->

# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-assertions-string","detectSteps":true} */}

# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create an account and check the status

// (test {"testId":"data-assertions-string","detectSteps":true})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the status</title></head>
<body>
<!-- test {"testId":"data-assertions-string","detectSteps":true} -->
<h1>Create an account and check the status</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create an account and check the status
======================================

.. test {"testId":"data-assertions-string","detectSteps":true}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-string">
  <title>Create an account and check the status</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-string","detectSteps":true}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-assertions-string","detectSteps":false} -->

# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-assertions-string","detectSteps":false} */}

# Create an account and check the status

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create an account and check the status

// (test {"testId":"data-assertions-string","detectSteps":false})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the status</title></head>
<body>
<!-- test {"testId":"data-assertions-string","detectSteps":false} -->
<h1>Create an account and check the status</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create an account and check the status
======================================

.. test {"testId":"data-assertions-string","detectSteps":false}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-string">
  <title>Create an account and check the status</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-string","detectSteps":false}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":"$$outputs.response.statusCode == 200"}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-assertions-string",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/accounts",
            "method": "post",
            "request": {
              "body": {
                "name": "Wren",
                "plan": "team"
              }
            }
          },
          "assertions": "$$outputs.response.statusCode == 200"
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-assertions-string
    steps:
      - httpRequest:
          url: http://localhost:8092/api/accounts
          method: post
          request:
            body:
              name: Wren
              plan: team
        assertions: $$outputs.response.statusCode == 200
```

### Array

**Varies:** `step.assertions` · **Value:** `["$$outputs.response.statusCode == 200", "$$outputs.response.body.plan == \"team\""]` · **Effect:** every check in the array must pass.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create an account and check the response

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the response</title></head>
<body>
<h1>Create an account and check the response</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create an account and check the response
========================================

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-array">
  <title>Create an account and check the response</title>
  <taskbody>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-assertions-array","detectSteps":true} -->

# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-assertions-array","detectSteps":true} */}

# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create an account and check the response

// (test {"testId":"data-assertions-array","detectSteps":true})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the response</title></head>
<body>
<!-- test {"testId":"data-assertions-array","detectSteps":true} -->
<h1>Create an account and check the response</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create an account and check the response
========================================

.. test {"testId":"data-assertions-array","detectSteps":true}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-array">
  <title>Create an account and check the response</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-array","detectSteps":true}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-assertions-array","detectSteps":false} -->

# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-assertions-array","detectSteps":false} */}

# Create an account and check the response

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create an account and check the response

// (test {"testId":"data-assertions-array","detectSteps":false})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create an account and check the response</title></head>
<body>
<!-- test {"testId":"data-assertions-array","detectSteps":false} -->
<h1>Create an account and check the response</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create an account and check the response
========================================

.. test {"testId":"data-assertions-array","detectSteps":false}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-array">
  <title>Create an account and check the response</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-array","detectSteps":false}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.body.plan == \"team\""]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-assertions-array",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/accounts",
            "method": "post",
            "request": {
              "body": {
                "name": "Wren",
                "plan": "team"
              }
            }
          },
          "assertions": [
            "$$outputs.response.statusCode == 200",
            "$$outputs.response.body.plan == \"team\""
          ]
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-assertions-array
    steps:
      - httpRequest:
          url: http://localhost:8092/api/accounts
          method: post
          request:
            body:
              name: Wren
              plan: team
        assertions:
          - $$outputs.response.statusCode == 200
          - $$outputs.response.body.plan == "team"
```

### Comparison operators

**Varies:** `step.assertions` · **Value:** `==`, `!=`, `>`, `<`, `>=`, `<=` · **Effect:** each operator compares the status code with a number.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the status code range

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the status code range</title></head>
<body>
<h1>Check the status code range</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the status code range
===========================

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-comparison">
  <title>Check the status code range</title>
  <taskbody>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-assertions-comparison","detectSteps":true} -->

# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-assertions-comparison","detectSteps":true} */}

# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the status code range

// (test {"testId":"data-assertions-comparison","detectSteps":true})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the status code range</title></head>
<body>
<!-- test {"testId":"data-assertions-comparison","detectSteps":true} -->
<h1>Check the status code range</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the status code range
===========================

.. test {"testId":"data-assertions-comparison","detectSteps":true}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-comparison">
  <title>Check the status code range</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-comparison","detectSteps":true}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode &gt; 199","$$outputs.response.statusCode &lt; 300","$$outputs.response.statusCode &gt;= 200","$$outputs.response.statusCode &lt;= 299"]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-assertions-comparison","detectSteps":false} -->

# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-assertions-comparison","detectSteps":false} */}

# Check the status code range

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the status code range

// (test {"testId":"data-assertions-comparison","detectSteps":false})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the status code range</title></head>
<body>
<!-- test {"testId":"data-assertions-comparison","detectSteps":false} -->
<h1>Check the status code range</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the status code range
===========================

.. test {"testId":"data-assertions-comparison","detectSteps":false}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode > 199","$$outputs.response.statusCode < 300","$$outputs.response.statusCode >= 200","$$outputs.response.statusCode <= 299"]}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-comparison">
  <title>Check the status code range</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-comparison","detectSteps":false}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.statusCode == 200","$$outputs.response.statusCode != 404","$$outputs.response.statusCode &gt; 199","$$outputs.response.statusCode &lt; 300","$$outputs.response.statusCode &gt;= 200","$$outputs.response.statusCode &lt;= 299"]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-assertions-comparison",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/accounts",
            "method": "post",
            "request": {
              "body": {
                "name": "Wren",
                "plan": "team"
              }
            }
          },
          "assertions": [
            "$$outputs.response.statusCode == 200",
            "$$outputs.response.statusCode != 404",
            "$$outputs.response.statusCode > 199",
            "$$outputs.response.statusCode < 300",
            "$$outputs.response.statusCode >= 200",
            "$$outputs.response.statusCode <= 299"
          ]
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-assertions-comparison
    steps:
      - httpRequest:
          url: http://localhost:8092/api/accounts
          method: post
          request:
            body:
              name: Wren
              plan: team
        assertions:
          - $$outputs.response.statusCode == 200
          - $$outputs.response.statusCode != 404
          - $$outputs.response.statusCode > 199
          - $$outputs.response.statusCode < 300
          - $$outputs.response.statusCode >= 200
          - $$outputs.response.statusCode <= 299
```

### Word operators

**Varies:** `step.assertions` · **Value:** `contains`, `oneOf`, `matches` · **Effect:** `contains` checks a substring, `oneOf` checks a list, and `matches` checks a regular expression.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the account fields

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the account fields</title></head>
<body>
<h1>Check the account fields</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre></li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the account fields
========================

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-word">
  <title>Check the account fields</title>
  <taskbody>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock></info></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"data-assertions-word","detectSteps":true} -->

# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} -->

<!-- test end -->
````

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"data-assertions-word","detectSteps":true} */}

# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} */}

{/* test end */}
````

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the account fields

// (test {"testId":"data-assertions-word","detectSteps":true})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the account fields</title></head>
<body>
<!-- test {"testId":"data-assertions-word","detectSteps":true} -->
<h1>Check the account fields</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the account fields
========================

.. test {"testId":"data-assertions-word","detectSteps":true}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-word">
  <title>Check the account fields</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-word","detectSteps":true}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"data-assertions-word","detectSteps":false} -->

# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} -->

<!-- test end -->
````

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"data-assertions-word","detectSteps":false} */}

# Check the account fields

1. Create an account. Send a `POST` request to `http://localhost:8092/api/accounts` with this body:

   ```json
   {"name":"Wren","plan":"team"}
   ```
   {/* step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} */}

{/* test end */}
````

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the account fields

// (test {"testId":"data-assertions-word","detectSteps":false})

. Create an account. Send a `+POST+` request to `+http://localhost:8092/api/accounts+` with this body:
+
[source,json]
----
{"name":"Wren","plan":"team"}
----
+
// (step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the account fields</title></head>
<body>
<!-- test {"testId":"data-assertions-word","detectSteps":false} -->
<h1>Check the account fields</h1>
<ol>
  <li>Create an account. Send a <code>POST</code> request to <code>http://localhost:8092/api/accounts</code> with this body:
    <pre><code class="language-json">{"name":"Wren","plan":"team"}</code></pre>
    <!-- step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the account fields
========================

.. test {"testId":"data-assertions-word","detectSteps":false}

#. Create an account. Send a ``POST`` request to ``http://localhost:8092/api/accounts`` with this body:

   .. code-block:: json

      {"name":"Wren","plan":"team"}

   .. step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-assertions-word">
  <title>Check the account fields</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-assertions-word","detectSteps":false}'/>
    <steps>
      <step><cmd>Create an account. Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/accounts</codeph> with this body:</cmd>
        <info><codeblock outputclass="language-json">{"name":"Wren","plan":"team"}</codeblock>
          <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/accounts","method":"post","request":{"body":{"name":"Wren","plan":"team"}}},"assertions":["$$outputs.response.body.name contains \"Wr\"","$$outputs.response.body.plan oneOf [free, team, enterprise]","$$outputs.response.body.name matches /^W[a-z]+$/"]}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-assertions-word",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/accounts",
            "method": "post",
            "request": {
              "body": {
                "name": "Wren",
                "plan": "team"
              }
            }
          },
          "assertions": [
            "$$outputs.response.body.name contains \"Wr\"",
            "$$outputs.response.body.plan oneOf [free, team, enterprise]",
            "$$outputs.response.body.name matches /^W[a-z]+$/"
          ]
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-assertions-word
    steps:
      - httpRequest:
          url: http://localhost:8092/api/accounts
          method: post
          request:
            body:
              name: Wren
              plan: team
        assertions:
          - $$outputs.response.body.name contains "Wr"
          - $$outputs.response.body.plan oneOf [free, team, enterprise]
          - $$outputs.response.body.name matches /^W[a-z]+$/
```

## Context `retries` permutations

### `retries: 0`

**Varies:** `context.retries` · **Value:** `0` · **Effect:** turns off context retries, so a crashed browser session fails the test at once.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Echo a name on a page

. Open `+http://localhost:8092/type-echo.html+`.
. Type `+Wren+` in the field.
. Check that the page shows `+Wren+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.</li>
  <li>Type <code>Wren</code> in the field.</li>
  <li>Check that the page shows <code>Wren</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Echo a name on a page
=====================

#. Open ``http://localhost:8092/type-echo.html``.

#. Type ``Wren`` in the field.

#. Check that the page shows ``Wren``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-0">
  <title>Echo a name on a page</title>
  <taskbody>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true} -->

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true} */}

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Echo a name on a page

// (test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<!-- test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true} -->
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Echo a name on a page
=====================

.. test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"#echo","elementText":"Wren"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-0">
  <title>Echo a name on a page</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":true}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false} -->

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false} */}

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Echo a name on a page

// (test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<!-- test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false} -->
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Echo a name on a page
=====================

.. test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"#echo","elementText":"Wren"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-0">
  <title>Echo a name on a page</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-context-retries-0","contexts":[{"retries":0}],"detectSteps":false}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-context-retries-0",
      "contexts": [
        {
          "retries": 0
        }
      ],
      "steps": [
        {
          "goTo": "http://localhost:8092/type-echo.html"
        },
        {
          "type": {
            "keys": "Wren",
            "selector": "#type-input"
          }
        },
        {
          "find": {
            "selector": "#echo",
            "elementText": "Wren"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-context-retries-0
    contexts:
      - retries: 0
    steps:
      - goTo: http://localhost:8092/type-echo.html
      - type:
          keys: Wren
          selector: "#type-input"
      - find:
          selector: "#echo"
          elementText: Wren
```

### `retries: 2`

**Varies:** `context.retries` · **Value:** `2` · **Effect:** runs the test again on a fresh browser session, up to twice, if the session crashes or never loads a page. A missing element isn't retried.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
2. Type `Wren` in the field.
3. Check that the page shows `Wren`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Echo a name on a page

. Open `+http://localhost:8092/type-echo.html+`.
. Type `+Wren+` in the field.
. Check that the page shows `+Wren+`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.</li>
  <li>Type <code>Wren</code> in the field.</li>
  <li>Check that the page shows <code>Wren</code>.</li>
</ol>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Echo a name on a page
=====================

#. Open ``http://localhost:8092/type-echo.html``.

#. Type ``Wren`` in the field.

#. Check that the page shows ``Wren``.
```

#### DITA

**`prose.dita`**

```xml title="prose.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-2">
  <title>Echo a name on a page</title>
  <taskbody>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd></step>
    </steps>
  </taskbody>
</task>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true} -->

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true} */}

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Echo a name on a page

// (test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<!-- test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true} -->
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Echo a name on a page
=====================

.. test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"#echo","elementText":"Wren"}}

.. test end
```

#### DITA

**`detected.dita`**

```xml title="detected.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-2">
  <title>Echo a name on a page</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":true}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false} -->

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   <!-- step {"goTo":"http://localhost:8092/type-echo.html"} -->
2. Type `Wren` in the field.
   <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} -->
3. Check that the page shows `Wren`.
   <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} -->

<!-- test end -->
```

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false} */}

# Echo a name on a page

1. Open `http://localhost:8092/type-echo.html`.
   {/* step {"goTo":"http://localhost:8092/type-echo.html"} */}
2. Type `Wren` in the field.
   {/* step {"type":{"keys":"Wren","selector":"#type-input"}} */}
3. Check that the page shows `Wren`.
   {/* step {"find":{"selector":"#echo","elementText":"Wren"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Echo a name on a page

// (test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false})

. Open `+http://localhost:8092/type-echo.html+`.
+
// (step {"goTo":"http://localhost:8092/type-echo.html"})
. Type `+Wren+` in the field.
+
// (step {"type":{"keys":"Wren","selector":"#type-input"}})
. Check that the page shows `+Wren+`.
+
// (step {"find":{"selector":"#echo","elementText":"Wren"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Echo a name on a page</title></head>
<body>
<!-- test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false} -->
<h1>Echo a name on a page</h1>
<ol>
  <li>Open <code>http://localhost:8092/type-echo.html</code>.
    <!-- step {"goTo":"http://localhost:8092/type-echo.html"} --></li>
  <li>Type <code>Wren</code> in the field.
    <!-- step {"type":{"keys":"Wren","selector":"#type-input"}} --></li>
  <li>Check that the page shows <code>Wren</code>.
    <!-- step {"find":{"selector":"#echo","elementText":"Wren"}} --></li>
</ol>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Echo a name on a page
=====================

.. test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false}

#. Open ``http://localhost:8092/type-echo.html``.

   .. step {"goTo":"http://localhost:8092/type-echo.html"}

#. Type ``Wren`` in the field.

   .. step {"type":{"keys":"Wren","selector":"#type-input"}}

#. Check that the page shows ``Wren``.

   .. step {"find":{"selector":"#echo","elementText":"Wren"}}

.. test end
```

#### DITA

**`inline.dita`**

```xml title="inline.dita"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="data-context-retries-2">
  <title>Echo a name on a page</title>
  <taskbody>
    <data name="doc-detective" value='test {"testId":"data-context-retries-2","contexts":[{"retries":2}],"detectSteps":false}'/>
    <steps>
      <step><cmd>Open <codeph>http://localhost:8092/type-echo.html</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"goTo":"http://localhost:8092/type-echo.html"}'/></info></step>
      <step><cmd>Type <codeph>Wren</codeph> in the field.</cmd>
        <info><data name="doc-detective" value='step {"type":{"keys":"Wren","selector":"#type-input"}}'/></info></step>
      <step><cmd>Check that the page shows <codeph>Wren</codeph>.</cmd>
        <info><data name="doc-detective" value='step {"find":{"selector":"#echo","elementText":"Wren"}}'/></info></step>
    </steps>
    <data name="doc-detective" value="test end"/>
  </taskbody>
</task>
```

#### Standalone

#### JSON

**`standalone.spec.json`**

```json title="standalone.spec.json"
{
  "$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json",
  "tests": [
    {
      "testId": "data-context-retries-2",
      "contexts": [
        {
          "retries": 2
        }
      ],
      "steps": [
        {
          "goTo": "http://localhost:8092/type-echo.html"
        },
        {
          "type": {
            "keys": "Wren",
            "selector": "#type-input"
          }
        },
        {
          "find": {
            "selector": "#echo",
            "elementText": "Wren"
          }
        }
      ]
    }
  ]
}
```

#### YAML

**`standalone.spec.yaml`**

```yaml title="standalone.spec.yaml"
# yaml-language-server: $schema=https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/dist/schemas/spec_v3.schema.json
tests:
  - testId: data-context-retries-2
    contexts:
      - retries: 2
    steps:
      - goTo: http://localhost:8092/type-echo.html
      - type:
          keys: Wren
          selector: "#type-input"
      - find:
          selector: "#echo"
          elementText: Wren
```