> 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.

# HTTP requests and code, written as tests

> Procedures that call an API, use an OpenAPI description, stub browser requests, and run shell commands and code, shown as prose, detected tests, inline tests, and a standalone spec.

Each example on this page shows one documented 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).

The examples call the echo API that the docs test server runs at `http://localhost:8092/api/` and `http://localhost:8093/api/`. Each returns the request's body, or its query parameters for a `GET` request. The `8092` server also adds an `extraField` field to each response.

## Create and list users with an API

This procedure uses [`httpRequest`](/docs/actions/httprequest) as a URL string and as an object with `url`, `method`, `request.headers`, `request.parameters`, `request.body`, `statusCodes`, `response.headers`, `response.body`, `response.required`, `allowAdditionalFields`, `timeout`, `path`, `directory`, `maxVariation`, and `overwrite`. See the [`httpRequest`](/reference/schemas/httprequest) reference.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

The response echoes the array.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

The response echoes the array.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

To create a user, send a `POST` request with the user as JSON:

[source,http]
----
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
----

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

----
GET http://localhost:8092/api/users?page=2
X-Test: docs
----

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

[source,http]
----
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
----

The response echoes the array.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create and list users</title></head>
<body>
<h1>Create and list users</h1>
<p>Check that the API is up: send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</p>
<p>To create a user, send a <code>POST</code> request with the user as JSON:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</code></pre>
<p>The response echoes the user you sent.</p>
<p>To list the second page of users, send a <code>GET</code> request with the <code>page</code> parameter:</p>
<pre><code>GET http://localhost:8092/api/users?page=2
X-Test: docs</code></pre>
<p>The response echoes the <code>page</code> parameter, and its <code>x-echo-test</code> header repeats the <code>X-Test</code> header you sent.</p>
<p>To create several users at once, send them as a JSON array:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</code></pre>
<p>The response echoes the array.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create and list users
=====================

Check that the API is up: send a ``GET`` request to ``http://localhost:8092/api/health``.

To create a user, send a ``POST`` request with the user as JSON:

.. code-block:: http

   POST http://localhost:8093/api/users HTTP/1.1
   Content-Type: application/json

   {"name": "Ada", "job": "engineer"}

The response echoes the user you sent.

To list the second page of users, send a ``GET`` request with the ``page`` parameter::

   GET http://localhost:8092/api/users?page=2
   X-Test: docs

The response echoes the ``page`` parameter, and its ``x-echo-test`` header repeats the ``X-Test`` header you sent.

To create several users at once, send them as a JSON array:

.. code-block:: http

   POST http://localhost:8093/api/users/batch HTTP/1.1
   Content-Type: application/json

   [{"name": "Ada"}, {"name": "Grace"}]

The response echoes the array.
```

#### 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="http-api">
  <title>Create and list users</title>
  <body>
    <p>Check that the API is up: send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</p>
    <p>To create a user, send a <codeph>POST</codeph> request with the user as JSON:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</codeblock>
    <p>The response echoes the user you sent.</p>
    <p>To list the second page of users, send a <codeph>GET</codeph> request with the <codeph>page</codeph> parameter:</p>
    <codeblock>GET http://localhost:8092/api/users?page=2
X-Test: docs</codeblock>
    <p>The response echoes the <codeph>page</codeph> parameter, and its <codeph>x-echo-test</codeph> header repeats the <codeph>X-Test</codeph> header you sent.</p>
    <p>To create several users at once, send them as a JSON array:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</codeblock>
    <p>The response echoes the array.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

<!-- step {"httpRequest":"http://localhost:8092/api/health"} -->

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

The response echoes the array.

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-api","detectSteps":true} */}

# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

{/* step {"httpRequest":"http://localhost:8092/api/health"} */}

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

The response echoes the array.

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create and list users

// (test {"testId":"http-api","detectSteps":true})

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

// (step {"httpRequest":"http://localhost:8092/api/health"})

To create a user, send a `POST` request with the user as JSON:

[source,http]
----
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
----

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

----
GET http://localhost:8092/api/users?page=2
X-Test: docs
----

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

[source,http]
----
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
----

The response echoes the array.

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create and list users</title></head>
<body>
<!-- test {"testId":"http-api","detectSteps":true} -->
<h1>Create and list users</h1>
<p>Check that the API is up: send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</p>
<!-- step {"httpRequest":"http://localhost:8092/api/health"} -->
<p>To create a user, send a <code>POST</code> request with the user as JSON:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</code></pre>
<p>The response echoes the user you sent.</p>
<p>To list the second page of users, send a <code>GET</code> request with the <code>page</code> parameter:</p>
<pre><code>GET http://localhost:8092/api/users?page=2
X-Test: docs</code></pre>
<p>The response echoes the <code>page</code> parameter, and its <code>x-echo-test</code> header repeats the <code>X-Test</code> header you sent.</p>
<p>To create several users at once, send them as a JSON array:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</code></pre>
<p>The response echoes the array.</p>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create and list users
=====================

.. test {"testId":"http-api","detectSteps":true}

Check that the API is up: send a ``GET`` request to ``http://localhost:8092/api/health``.

.. step {"httpRequest":"http://localhost:8092/api/health"}

To create a user, send a ``POST`` request with the user as JSON:

.. code-block:: http

   POST http://localhost:8093/api/users HTTP/1.1
   Content-Type: application/json

   {"name": "Ada", "job": "engineer"}

The response echoes the user you sent.

To list the second page of users, send a ``GET`` request with the ``page`` parameter::

   GET http://localhost:8092/api/users?page=2
   X-Test: docs

The response echoes the ``page`` parameter, and its ``x-echo-test`` header repeats the ``X-Test`` header you sent.

To create several users at once, send them as a JSON array:

.. code-block:: http

   POST http://localhost:8093/api/users/batch HTTP/1.1
   Content-Type: application/json

   [{"name": "Ada"}, {"name": "Grace"}]

The response echoes the array.

.. 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="http-api">
  <title>Create and list users</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-api","detectSteps":true}'/>
    <p>Check that the API is up: send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":"http://localhost:8092/api/health"}'/>
    <p>To create a user, send a <codeph>POST</codeph> request with the user as JSON:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</codeblock>
    <p>The response echoes the user you sent.</p>
    <p>To list the second page of users, send a <codeph>GET</codeph> request with the <codeph>page</codeph> parameter:</p>
    <codeblock>GET http://localhost:8092/api/users?page=2
X-Test: docs</codeblock>
    <p>The response echoes the <codeph>page</codeph> parameter, and its <codeph>x-echo-test</codeph> header repeats the <codeph>X-Test</codeph> header you sent.</p>
    <p>To create several users at once, send them as a JSON array:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</codeblock>
    <p>The response echoes the array.</p>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

<!-- step {"httpRequest":"http://localhost:8092/api/health"} -->

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}} -->

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}} -->

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->

The response echoes the array.

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-api","detectSteps":false} */}

# Create and list users

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

{/* step {"httpRequest":"http://localhost:8092/api/health"} */}

To create a user, send a `POST` request with the user as JSON:

```http
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
```

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}} */}

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

```
GET http://localhost:8092/api/users?page=2
X-Test: docs
```

{/* step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}} */}

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

```http
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
```

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} */}

The response echoes the array.

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create and list users

// (test {"testId":"http-api","detectSteps":false})

Check that the API is up: send a `GET` request to `http://localhost:8092/api/health`.

// (step {"httpRequest":"http://localhost:8092/api/health"})

To create a user, send a `POST` request with the user as JSON:

[source,http]
----
POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}
----

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}})

The response echoes the user you sent.

To list the second page of users, send a `GET` request with the `page` parameter:

----
GET http://localhost:8092/api/users?page=2
X-Test: docs
----

// (step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}})

The response echoes the `page` parameter, and its `x-echo-test` header repeats the `X-Test` header you sent.

To create several users at once, send them as a JSON array:

[source,http]
----
POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]
----

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}})

The response echoes the array.

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create and list users</title></head>
<body>
<!-- test {"testId":"http-api","detectSteps":false} -->
<h1>Create and list users</h1>
<p>Check that the API is up: send a <code>GET</code> request to <code>http://localhost:8092/api/health</code>.</p>
<!-- step {"httpRequest":"http://localhost:8092/api/health"} -->
<p>To create a user, send a <code>POST</code> request with the user as JSON:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</code></pre>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}} -->
<p>The response echoes the user you sent.</p>
<p>To list the second page of users, send a <code>GET</code> request with the <code>page</code> parameter:</p>
<pre><code>GET http://localhost:8092/api/users?page=2
X-Test: docs</code></pre>
<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}} -->
<p>The response echoes the <code>page</code> parameter, and its <code>x-echo-test</code> header repeats the <code>X-Test</code> header you sent.</p>
<p>To create several users at once, send them as a JSON array:</p>
<pre><code class="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</code></pre>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->
<p>The response echoes the array.</p>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create and list users
=====================

.. test {"testId":"http-api","detectSteps":false}

Check that the API is up: send a ``GET`` request to ``http://localhost:8092/api/health``.

.. step {"httpRequest":"http://localhost:8092/api/health"}

To create a user, send a ``POST`` request with the user as JSON:

.. code-block:: http

   POST http://localhost:8093/api/users HTTP/1.1
   Content-Type: application/json

   {"name": "Ada", "job": "engineer"}

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}}

The response echoes the user you sent.

To list the second page of users, send a ``GET`` request with the ``page`` parameter::

   GET http://localhost:8092/api/users?page=2
   X-Test: docs

.. step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}}

The response echoes the ``page`` parameter, and its ``x-echo-test`` header repeats the ``X-Test`` header you sent.

To create several users at once, send them as a JSON array:

.. code-block:: http

   POST http://localhost:8093/api/users/batch HTTP/1.1
   Content-Type: application/json

   [{"name": "Ada"}, {"name": "Grace"}]

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}

The response echoes the array.

.. 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="http-api">
  <title>Create and list users</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-api","detectSteps":false}'/>
    <p>Check that the API is up: send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/api/health</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":"http://localhost:8092/api/health"}'/>
    <p>To create a user, send a <codeph>POST</codeph> request with the user as JSON:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "job": "engineer"}</codeblock>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":"Content-Type: application/json","body":"{\"name\": \"Ada\", \"job\": \"engineer\"}"},"statusCodes":[200,201],"response":{"body":{"name":"Ada","job":"engineer"}},"allowAdditionalFields":false}}'/>
    <p>The response echoes the user you sent.</p>
    <p>To list the second page of users, send a <codeph>GET</codeph> request with the <codeph>page</codeph> parameter:</p>
    <codeblock>GET http://localhost:8092/api/users?page=2
X-Test: docs</codeblock>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"get","request":{"headers":{"X-Test":"docs"},"parameters":{"page":"2"}},"statusCodes":200,"timeout":10000,"response":{"headers":{"x-echo-test":"docs"},"body":{"page":"2"},"required":["page"]},"path":"users-page-2.json","directory":"responses","maxVariation":0.1,"overwrite":"aboveVariation"}}'/>
    <p>The response echoes the <codeph>page</codeph> parameter, and its <codeph>x-echo-test</codeph> header repeats the <codeph>X-Test</codeph> header you sent.</p>
    <p>To create several users at once, send them as a JSON array:</p>
    <codeblock outputclass="language-http">POST http://localhost:8093/api/users/batch HTTP/1.1
Content-Type: application/json

[{"name": "Ada"}, {"name": "Grace"}]</codeblock>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}'/>
    <p>The response echoes the array.</p>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-api",
      "steps": [
        {
          "httpRequest": "http://localhost:8092/api/health"
        },
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "method": "post",
            "request": {
              "headers": "Content-Type: application/json",
              "body": "{\"name\": \"Ada\", \"job\": \"engineer\"}"
            },
            "statusCodes": [
              200,
              201
            ],
            "response": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            },
            "allowAdditionalFields": false
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/users",
            "method": "get",
            "request": {
              "headers": {
                "X-Test": "docs"
              },
              "parameters": {
                "page": "2"
              }
            },
            "statusCodes": 200,
            "timeout": 10000,
            "response": {
              "headers": {
                "x-echo-test": "docs"
              },
              "body": {
                "page": "2"
              },
              "required": [
                "page"
              ]
            },
            "path": "users-page-2.json",
            "directory": "responses",
            "maxVariation": 0.1,
            "overwrite": "aboveVariation"
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users/batch",
            "method": "post",
            "request": {
              "headers": {
                "Content-Type": "application/json"
              },
              "body": [
                {
                  "name": "Ada"
                },
                {
                  "name": "Grace"
                }
              ]
            },
            "response": {
              "body": [
                {
                  "name": "Ada"
                },
                {
                  "name": "Grace"
                }
              ]
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-api
    steps:
      - httpRequest: http://localhost:8092/api/health
      - httpRequest:
          url: http://localhost:8093/api/users
          method: post
          request:
            headers: "Content-Type: application/json"
            body: '{"name": "Ada", "job": "engineer"}'
          statusCodes:
            - 200
            - 201
          response:
            body:
              name: Ada
              job: engineer
          allowAdditionalFields: false
      - httpRequest:
          url: http://localhost:8092/api/users
          method: get
          request:
            headers:
              X-Test: docs
            parameters:
              page: "2"
          statusCodes: 200
          timeout: 10000
          response:
            headers:
              x-echo-test: docs
            body:
              page: "2"
            required:
              - page
          path: users-page-2.json
          directory: responses
          maxVariation: 0.1
          overwrite: aboveVariation
      - httpRequest:
          url: http://localhost:8093/api/users/batch
          method: post
          request:
            headers:
              Content-Type: application/json
            body:
              - name: Ada
              - name: Grace
          response:
            body:
              - name: Ada
              - name: Grace
```

### What detection finds

Default detection turns each code block that holds a raw HTTP request into an `httpRequest` step, whether the block is tagged `http` or has no language. The detected step takes the method, the URL, the headers, and the body from the block. It parses a JSON body into an object or an array. It doesn't check the response, so it passes on any `200` or `201` status.

The health check sits in inline code, which detection skips, so the detected variant adds it with a `step` statement.

The inline and standalone variants also check each response:

* The `POST` step sends its headers as a `Name: value` string and its body as a JSON string. With `allowAdditionalFields` set to `false`, the response must hold only the fields in `response.body`. That's why this step calls the `8093` server, which adds no fields.
* The `GET` step sends its headers as an object and its query as `request.parameters`, and sets `statusCodes` to a single number. It saves the response to `users-page-2.json` in the `responses` folder next to the test file, and compares later responses to that file. A response that differs by more than `maxVariation`, 10% here, returns a warning and, with `overwrite` set to `aboveVariation`, replaces the file.
* The batch step sends an array as `request.body` and expects the same array as `response.body`.

## Call operations from an OpenAPI description

This procedure loads an OpenAPI description with the test's [`openApi`](/reference/schemas/openapi) list, then calls its operations from [`httpRequest`](/docs/actions/httprequest) steps. The steps set `openApi` as an operation ID string and as an object with `name`, `operationId`, `useExample`, `server`, `statusCode`, `mockResponse`, `exampleKey`, and `validateAgainstSchema`. The description entry sets `name`, `descriptionPath`, `validateAgainstSchema`, and `headers` as a `Name: value` string. The first step adds `headers` as an object.

The example's description, `users.openapi.json`, sits next to the test files and points at the `8093` server.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create a user from the API description</title></head>
<body>
<h1>Create a user from the API description</h1>
<p>The Users API description, <code>users.openapi.json</code>, defines each operation with an example.</p>
<p>Call the <code>createUser</code> operation with its example request. The response matches the example user, Ada.</p>
<p>Call <code>createUser</code> again with your own user. The response includes the <code>name</code> and <code>job</code> fields.</p>
<p>The <code>getUser</code> operation isn't live yet, so preview its response from the description's <code>ada</code> example.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Create a user from the API description
======================================

The Users API description, ``users.openapi.json``, defines each operation with an example.

Call the ``createUser`` operation with its example request. The response matches the example user, Ada.

Call ``createUser`` again with your own user. The response includes the ``name`` and ``job`` fields.

The ``getUser`` operation isn't live yet, so preview its response from the description's ``ada`` example.
```

#### 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="http-openapi">
  <title>Create a user from the API description</title>
  <body>
    <p>The Users API description, <codeph>users.openapi.json</codeph>, defines each operation with an example.</p>
    <p>Call the <codeph>createUser</codeph> operation with its example request. The response matches the example user, Ada.</p>
    <p>Call <codeph>createUser</codeph> again with your own user. The response includes the <codeph>name</codeph> and <codeph>job</codeph> fields.</p>
    <p>The <codeph>getUser</codeph> operation isn't live yet, so preview its response from the description's <codeph>ada</codeph> example.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} -->

# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

<!-- step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} -->

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} -->

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} */}

# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

{/* step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} */}

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} */}

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

{/* step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Create a user from the API description

// (test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]})

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

// (step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}})

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}})

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

// (step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create a user from the API description</title></head>
<body>
<!-- test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} -->
<h1>Create a user from the API description</h1>
<p>The Users API description, <code>users.openapi.json</code>, defines each operation with an example.</p>
<p>Call the <code>createUser</code> operation with its example request. The response matches the example user, Ada.</p>
<!-- step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} -->
<p>Call <code>createUser</code> again with your own user. The response includes the <code>name</code> and <code>job</code> fields.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} -->
<p>The <code>getUser</code> operation isn't live yet, so preview its response from the description's <code>ada</code> example.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Create a user from the API description
======================================

.. test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]}

The Users API description, ``users.openapi.json``, defines each operation with an example.

Call the ``createUser`` operation with its example request. The response matches the example user, Ada.

.. step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}}

Call ``createUser`` again with your own user. The response includes the ``name`` and ``job`` fields.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}}

The ``getUser`` operation isn't live yet, so preview its response from the description's ``ada`` example.

.. step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi">
  <title>Create a user from the API description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]}'/>
    <p>The Users API description, <codeph>users.openapi.json</codeph>, defines each operation with an example.</p>
    <p>Call the <codeph>createUser</codeph> operation with its example request. The response matches the example user, Ada.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}}'/>
    <p>Call <codeph>createUser</codeph> again with your own user. The response includes the <codeph>name</codeph> and <codeph>job</codeph> fields.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}}'/>
    <p>The <codeph>getUser</codeph> operation isn't live yet, so preview its response from the description's <codeph>ada</codeph> example.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} -->

# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

<!-- step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} -->

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} -->

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} */}

# Create a user from the API description

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

{/* step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} */}

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} */}

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

{/* step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Create a user from the API description

// (test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]})

The Users API description, `users.openapi.json`, defines each operation with an example.

Call the `createUser` operation with its example request. The response matches the example user, Ada.

// (step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}})

Call `createUser` again with your own user. The response includes the `name` and `job` fields.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}})

The `getUser` operation isn't live yet, so preview its response from the description's `ada` example.

// (step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Create a user from the API description</title></head>
<body>
<!-- test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]} -->
<h1>Create a user from the API description</h1>
<p>The Users API description, <code>users.openapi.json</code>, defines each operation with an example.</p>
<p>Call the <code>createUser</code> operation with its example request. The response matches the example user, Ada.</p>
<!-- step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}} -->
<p>Call <code>createUser</code> again with your own user. The response includes the <code>name</code> and <code>job</code> fields.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}} -->
<p>The <code>getUser</code> operation isn't live yet, so preview its response from the description's <code>ada</code> example.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Create a user from the API description
======================================

.. test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]}

The Users API description, ``users.openapi.json``, defines each operation with an example.

Call the ``createUser`` operation with its example request. The response matches the example user, Ada.

.. step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}}

Call ``createUser`` again with your own user. The response includes the ``name`` and ``job`` fields.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}}

The ``getUser`` operation isn't live yet, so preview its response from the description's ``ada`` example.

.. step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi">
  <title>Create a user from the API description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"users.openapi.json","validateAgainstSchema":"both","headers":"X-Test: docs"}]}'/>
    <p>The Users API description, <codeph>users.openapi.json</codeph>, defines each operation with an example.</p>
    <p>Call the <codeph>createUser</codeph> operation with its example request. The response matches the example user, Ada.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"name":"users","operationId":"createUser","headers":{"X-Request-Source":"docs"},"useExample":"both","server":"http://localhost:8093/api","statusCode":200}}}'/>
    <p>Call <codeph>createUser</codeph> again with your own user. The response includes the <codeph>name</codeph> and <codeph>job</codeph> fields.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Grace","job":"admiral"}},"response":{"body":{"name":"Grace"},"required":["name","job"]}}}'/>
    <p>The <codeph>getUser</codeph> operation isn't live yet, so preview its response from the description's <codeph>ada</codeph> example.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "users.openapi.json",
          "validateAgainstSchema": "both",
          "headers": "X-Test: docs"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "name": "users",
              "operationId": "createUser",
              "headers": {
                "X-Request-Source": "docs"
              },
              "useExample": "both",
              "server": "http://localhost:8093/api",
              "statusCode": 200
            }
          }
        },
        {
          "httpRequest": {
            "openApi": "createUser",
            "request": {
              "body": {
                "name": "Grace",
                "job": "admiral"
              }
            },
            "response": {
              "body": {
                "name": "Grace"
              },
              "required": [
                "name",
                "job"
              ]
            }
          }
        },
        {
          "httpRequest": {
            "openApi": {
              "operationId": "getUser",
              "mockResponse": true,
              "useExample": "response",
              "exampleKey": "ada",
              "validateAgainstSchema": "response"
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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
openApi:
  - name: users
    descriptionPath: users.openapi.json
    validateAgainstSchema: both
    headers: "X-Test: docs"
tests:
  - testId: http-openapi
    steps:
      - httpRequest:
          openApi:
            name: users
            operationId: createUser
            headers:
              X-Request-Source: docs
            useExample: both
            server: http://localhost:8093/api
            statusCode: 200
      - httpRequest:
          openApi: createUser
          request:
            body:
              name: Grace
              job: admiral
          response:
            body:
              name: Grace
            required:
              - name
              - job
      - httpRequest:
          openApi:
            operationId: getUser
            mockResponse: true
            useExample: response
            exampleKey: ada
            validateAgainstSchema: response
          response:
            body:
              name: Ada
```

### Notes

* Detection finds no steps here, so each variant carries its steps in statements. The `test` statement and the JSON spec's test hold the `openApi` list. The YAML spec sets the same list on the [spec](/reference/schemas/specification) instead, where every test in the spec shares it. Both resolve to the same test.
* The first step sends the operation's request example and checks the response against its response example. The second sends its own body, and validates both against the description's schema.
* The third step sets `mockResponse`, so Doc Detective sends no request. It returns the `ada` response example as the response instead, which lets you test against an operation before it's live.

## Stub API responses in the browser

This procedure stubs requests with [`mockRequest`](/docs/actions/mockrequest), using `url`, `method`, and `response` with `statusCode`, `headers`, `body`, and `bodyPath`. It then opens a page with [`goTo`](/docs/actions/goto) and runs JavaScript in it with [`runBrowserScript`](/docs/actions/runbrowserscript), as a script string and as an object with `surface`, `script`, `args`, `output`, `timeout`, `path`, `directory`, `maxVariation`, and `overwrite`. See the [`mockRequest`](/reference/schemas/mockrequest) and [`runBrowserScript`](/reference/schemas/runbrowserscript) references.

The `invoices.json` file next to the test files holds the stubbed response body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

Stub the notices endpoint with one billing notice.

Stub the status endpoint so that it reports `OK`.

Open the test site at `http://localhost:8092/`.

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

Fetch `/api/status`. The response is the text `OK`.

Check the page title by evaluating `document.title` in the console.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

Stub the notices endpoint with one billing notice.

Stub the status endpoint so that it reports `OK`.

Open the test site at `http://localhost:8092/`.

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

Fetch `/api/status`. The response is the text `OK`.

Check the page title by evaluating `document.title` in the console.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

Stub the notices endpoint with one billing notice.

Stub the status endpoint so that it reports `OK`.

Open the test site at `http://localhost:8092/`.

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

Fetch `/api/status`. The response is the text `OK`.

Check the page title by evaluating `document.title` in the console.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview invoices against a stubbed API</title></head>
<body>
<h1>Preview invoices against a stubbed API</h1>
<p>Stub the invoices endpoint so that every <code>GET</code> request returns the invoices in <code>invoices.json</code>.</p>
<p>Stub invoice creation too, so that a <code>POST</code> request returns a new invoice ID.</p>
<p>Stub the notices endpoint with one billing notice.</p>
<p>Stub the status endpoint so that it reports <code>OK</code>.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>In the browser console, fetch <code>/api/invoices?page=1</code>. The response lists invoice <code>inv-1</code>.</p>
<p>Send a <code>POST</code> request to <code>/api/invoices</code>. The response status is <code>201</code>, and the body is the new ID, <code>inv-2</code>.</p>
<p>Fetch <code>/api/notices</code>. The notice says when invoices are due, and matches the copy saved in <code>output/notices.json</code>.</p>
<p>Fetch <code>/api/status</code>. The response is the text <code>OK</code>.</p>
<p>Check the page title by evaluating <code>document.title</code> in the console.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Preview invoices against a stubbed API
======================================

Stub the invoices endpoint so that every ``GET`` request returns the invoices in ``invoices.json``.

Stub invoice creation too, so that a ``POST`` request returns a new invoice ID.

Stub the notices endpoint with one billing notice.

Stub the status endpoint so that it reports ``OK``.

Open the test site at ``http://localhost:8092/``.

In the browser console, fetch ``/api/invoices?page=1``. The response lists invoice ``inv-1``.

Send a ``POST`` request to ``/api/invoices``. The response status is ``201``, and the body is the new ID, ``inv-2``.

Fetch ``/api/notices``. The notice says when invoices are due, and matches the copy saved in ``output/notices.json``.

Fetch ``/api/status``. The response is the text ``OK``.

Check the page title by evaluating ``document.title`` in the console.
```

#### 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="http-mock-request">
  <title>Preview invoices against a stubbed API</title>
  <body>
    <p>Stub the invoices endpoint so that every <codeph>GET</codeph> request returns the invoices in <codeph>invoices.json</codeph>.</p>
    <p>Stub invoice creation too, so that a <codeph>POST</codeph> request returns a new invoice ID.</p>
    <p>Stub the notices endpoint with one billing notice.</p>
    <p>Stub the status endpoint so that it reports <codeph>OK</codeph>.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>In the browser console, fetch <codeph>/api/invoices?page=1</codeph>. The response lists invoice <codeph>inv-1</codeph>.</p>
    <p>Send a <codeph>POST</codeph> request to <codeph>/api/invoices</codeph>. The response status is <codeph>201</codeph>, and the body is the new ID, <codeph>inv-2</codeph>.</p>
    <p>Fetch <codeph>/api/notices</codeph>. The notice says when invoices are due, and matches the copy saved in <codeph>output/notices.json</codeph>.</p>
    <p>Fetch <codeph>/api/status</codeph>. The response is the text <codeph>OK</codeph>.</p>
    <p>Check the page title by evaluating <codeph>document.title</codeph> in the console.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

<!-- step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} -->

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

<!-- step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} -->

Stub the notices endpoint with one billing notice.

<!-- step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} -->

Stub the status endpoint so that it reports `OK`.

<!-- step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

<!-- step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} -->

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} -->

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

<!-- step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} -->

Fetch `/api/status`. The response is the text `OK`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} -->

Check the page title by evaluating `document.title` in the console.

<!-- step {"runBrowserScript":"return document.title;"} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

{/* step {"mockRequest":{"url":"**\/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} */}

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

{/* step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} */}

Stub the notices endpoint with one billing notice.

{/* step {"mockRequest":{"url":"**\/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} */}

Stub the status endpoint so that it reports `OK`.

{/* step {"mockRequest":{"url":"**\/api/status","response":{"body":"OK"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

{/* step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} */}

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} */}

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

{/* step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} */}

Fetch `/api/status`. The response is the text `OK`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} */}

Check the page title by evaluating `document.title` in the console.

{/* step {"runBrowserScript":"return document.title;"} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Preview invoices against a stubbed API

// (test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

// (step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}})

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

// (step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}})

Stub the notices endpoint with one billing notice.

// (step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}})

Stub the status endpoint so that it reports `OK`.

// (step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

// (step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}})

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

// (step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}})

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

// (step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}})

Fetch `/api/status`. The response is the text `OK`.

// (step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}})

Check the page title by evaluating `document.title` in the console.

// (step {"runBrowserScript":"return document.title;"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview invoices against a stubbed API</title></head>
<body>
<!-- test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Preview invoices against a stubbed API</h1>
<p>Stub the invoices endpoint so that every <code>GET</code> request returns the invoices in <code>invoices.json</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} -->
<p>Stub invoice creation too, so that a <code>POST</code> request returns a new invoice ID.</p>
<!-- step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} -->
<p>Stub the notices endpoint with one billing notice.</p>
<!-- step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} -->
<p>Stub the status endpoint so that it reports <code>OK</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>In the browser console, fetch <code>/api/invoices?page=1</code>. The response lists invoice <code>inv-1</code>.</p>
<!-- step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} -->
<p>Send a <code>POST</code> request to <code>/api/invoices</code>. The response status is <code>201</code>, and the body is the new ID, <code>inv-2</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} -->
<p>Fetch <code>/api/notices</code>. The notice says when invoices are due, and matches the copy saved in <code>output/notices.json</code>.</p>
<!-- step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} -->
<p>Fetch <code>/api/status</code>. The response is the text <code>OK</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} -->
<p>Check the page title by evaluating <code>document.title</code> in the console.</p>
<!-- step {"runBrowserScript":"return document.title;"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Preview invoices against a stubbed API
======================================

.. test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the invoices endpoint so that every ``GET`` request returns the invoices in ``invoices.json``.

.. step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}}

Stub invoice creation too, so that a ``POST`` request returns a new invoice ID.

.. step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}}

Stub the notices endpoint with one billing notice.

.. step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}}

Stub the status endpoint so that it reports ``OK``.

.. step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

In the browser console, fetch ``/api/invoices?page=1``. The response lists invoice ``inv-1``.

.. step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}}

Send a ``POST`` request to ``/api/invoices``. The response status is ``201``, and the body is the new ID, ``inv-2``.

.. step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}}

Fetch ``/api/notices``. The notice says when invoices are due, and matches the copy saved in ``output/notices.json``.

.. step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}}

Fetch ``/api/status``. The response is the text ``OK``.

.. step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}}

Check the page title by evaluating ``document.title`` in the console.

.. step {"runBrowserScript":"return document.title;"}

.. 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="http-mock-request">
  <title>Preview invoices against a stubbed API</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-request","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the invoices endpoint so that every <codeph>GET</codeph> request returns the invoices in <codeph>invoices.json</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}}'/>
    <p>Stub invoice creation too, so that a <codeph>POST</codeph> request returns a new invoice ID.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}}'/>
    <p>Stub the notices endpoint with one billing notice.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}}'/>
    <p>Stub the status endpoint so that it reports <codeph>OK</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>In the browser console, fetch <codeph>/api/invoices?page=1</codeph>. The response lists invoice <codeph>inv-1</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get(&apos;x-mock&apos;) + &apos; &apos; + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>/api/invoices</codeph>. The response status is <codeph>201</codeph>, and the body is the new ID, <codeph>inv-2</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/invoices&apos;, { method: &apos;POST&apos; }).then(async (r) => r.status + &apos; &apos; + (await r.json()).id);","output":"201 inv-2"}}'/>
    <p>Fetch <codeph>/api/notices</codeph>. The notice says when invoices are due, and matches the copy saved in <codeph>output/notices.json</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch(&apos;/api/notices&apos;).then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}}'/>
    <p>Fetch <codeph>/api/status</codeph>. The response is the text <codeph>OK</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/status&apos;).then((r) => r.text());","output":"OK"}}'/>
    <p>Check the page title by evaluating <codeph>document.title</codeph> in the console.</p>
    <data name="doc-detective" value='step {"runBrowserScript":"return document.title;"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

<!-- step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} -->

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

<!-- step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} -->

Stub the notices endpoint with one billing notice.

<!-- step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} -->

Stub the status endpoint so that it reports `OK`.

<!-- step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

<!-- step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} -->

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} -->

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

<!-- step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} -->

Fetch `/api/status`. The response is the text `OK`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} -->

Check the page title by evaluating `document.title` in the console.

<!-- step {"runBrowserScript":"return document.title;"} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Preview invoices against a stubbed API

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

{/* step {"mockRequest":{"url":"**\/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} */}

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

{/* step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} */}

Stub the notices endpoint with one billing notice.

{/* step {"mockRequest":{"url":"**\/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} */}

Stub the status endpoint so that it reports `OK`.

{/* step {"mockRequest":{"url":"**\/api/status","response":{"body":"OK"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

{/* step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} */}

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} */}

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

{/* step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} */}

Fetch `/api/status`. The response is the text `OK`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} */}

Check the page title by evaluating `document.title` in the console.

{/* step {"runBrowserScript":"return document.title;"} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Preview invoices against a stubbed API

// (test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the invoices endpoint so that every `GET` request returns the invoices in `invoices.json`.

// (step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}})

Stub invoice creation too, so that a `POST` request returns a new invoice ID.

// (step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}})

Stub the notices endpoint with one billing notice.

// (step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}})

Stub the status endpoint so that it reports `OK`.

// (step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

In the browser console, fetch `/api/invoices?page=1`. The response lists invoice `inv-1`.

// (step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}})

Send a `POST` request to `/api/invoices`. The response status is `201`, and the body is the new ID, `inv-2`.

// (step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}})

Fetch `/api/notices`. The notice says when invoices are due, and matches the copy saved in `output/notices.json`.

// (step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}})

Fetch `/api/status`. The response is the text `OK`.

// (step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}})

Check the page title by evaluating `document.title` in the console.

// (step {"runBrowserScript":"return document.title;"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview invoices against a stubbed API</title></head>
<body>
<!-- test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Preview invoices against a stubbed API</h1>
<p>Stub the invoices endpoint so that every <code>GET</code> request returns the invoices in <code>invoices.json</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}} -->
<p>Stub invoice creation too, so that a <code>POST</code> request returns a new invoice ID.</p>
<!-- step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}} -->
<p>Stub the notices endpoint with one billing notice.</p>
<!-- step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}} -->
<p>Stub the status endpoint so that it reports <code>OK</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>In the browser console, fetch <code>/api/invoices?page=1</code>. The response lists invoice <code>inv-1</code>.</p>
<!-- step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}} -->
<p>Send a <code>POST</code> request to <code>/api/invoices</code>. The response status is <code>201</code>, and the body is the new ID, <code>inv-2</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}} -->
<p>Fetch <code>/api/notices</code>. The notice says when invoices are due, and matches the copy saved in <code>output/notices.json</code>.</p>
<!-- step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}} -->
<p>Fetch <code>/api/status</code>. The response is the text <code>OK</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}} -->
<p>Check the page title by evaluating <code>document.title</code> in the console.</p>
<!-- step {"runBrowserScript":"return document.title;"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Preview invoices against a stubbed API
======================================

.. test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the invoices endpoint so that every ``GET`` request returns the invoices in ``invoices.json``.

.. step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}}

Stub invoice creation too, so that a ``POST`` request returns a new invoice ID.

.. step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}}

Stub the notices endpoint with one billing notice.

.. step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}}

Stub the status endpoint so that it reports ``OK``.

.. step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

In the browser console, fetch ``/api/invoices?page=1``. The response lists invoice ``inv-1``.

.. step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}}

Send a ``POST`` request to ``/api/invoices``. The response status is ``201``, and the body is the new ID, ``inv-2``.

.. step {"runBrowserScript":{"script":"return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);","output":"201 inv-2"}}

Fetch ``/api/notices``. The notice says when invoices are due, and matches the copy saved in ``output/notices.json``.

.. step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch('/api/notices').then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}}

Fetch ``/api/status``. The response is the text ``OK``.

.. step {"runBrowserScript":{"script":"return fetch('/api/status').then((r) => r.text());","output":"OK"}}

Check the page title by evaluating ``document.title`` in the console.

.. step {"runBrowserScript":"return document.title;"}

.. 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="http-mock-request">
  <title>Preview invoices against a stubbed API</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-request","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the invoices endpoint so that every <codeph>GET</codeph> request returns the invoices in <codeph>invoices.json</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/invoices*","method":"GET","response":{"statusCode":200,"headers":{"x-mock":"docs"},"bodyPath":"invoices.json"}}}'/>
    <p>Stub invoice creation too, so that a <codeph>POST</codeph> request returns a new invoice ID.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"http://localhost:8092/api/invoices","method":"POST","response":{"statusCode":201,"body":{"id":"inv-2"}}}}'/>
    <p>Stub the notices endpoint with one billing notice.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/notices","response":{"body":["Invoices are due on the 3rd of each month."]}}}'/>
    <p>Stub the status endpoint so that it reports <codeph>OK</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/status","response":{"body":"OK"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>In the browser console, fetch <codeph>/api/invoices?page=1</codeph>. The response lists invoice <codeph>inv-1</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"surface":"chrome","script":"return fetch(arguments[0]).then(async (r) => r.headers.get(&apos;x-mock&apos;) + &apos; &apos; + JSON.stringify(await r.json()));","args":["/api/invoices?page=1"],"output":"/^docs .*inv-1/","timeout":10000}}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>/api/invoices</codeph>. The response status is <codeph>201</codeph>, and the body is the new ID, <codeph>inv-2</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/invoices&apos;, { method: &apos;POST&apos; }).then(async (r) => r.status + &apos; &apos; + (await r.json()).id);","output":"201 inv-2"}}'/>
    <p>Fetch <codeph>/api/notices</codeph>. The notice says when invoices are due, and matches the copy saved in <codeph>output/notices.json</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"surface":{"browser":"chrome"},"script":"return fetch(&apos;/api/notices&apos;).then((r) => r.json());","output":"due on the 3rd","path":"notices.json","directory":"output","maxVariation":0,"overwrite":"false"}}'/>
    <p>Fetch <codeph>/api/status</codeph>. The response is the text <codeph>OK</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/status&apos;).then((r) => r.text());","output":"OK"}}'/>
    <p>Check the page title by evaluating <codeph>document.title</codeph> in the console.</p>
    <data name="doc-detective" value='step {"runBrowserScript":"return document.title;"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-request",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/invoices*",
            "method": "GET",
            "response": {
              "statusCode": 200,
              "headers": {
                "x-mock": "docs"
              },
              "bodyPath": "invoices.json"
            }
          }
        },
        {
          "mockRequest": {
            "url": "http://localhost:8092/api/invoices",
            "method": "POST",
            "response": {
              "statusCode": 201,
              "body": {
                "id": "inv-2"
              }
            }
          }
        },
        {
          "mockRequest": {
            "url": "**/api/notices",
            "response": {
              "body": [
                "Invoices are due on the 3rd of each month."
              ]
            }
          }
        },
        {
          "mockRequest": {
            "url": "**/api/status",
            "response": {
              "body": "OK"
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "surface": "chrome",
            "script": "return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));",
            "args": [
              "/api/invoices?page=1"
            ],
            "output": "/^docs .*inv-1/",
            "timeout": 10000
          }
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);",
            "output": "201 inv-2"
          }
        },
        {
          "runBrowserScript": {
            "surface": {
              "browser": "chrome"
            },
            "script": "return fetch('/api/notices').then((r) => r.json());",
            "output": "due on the 3rd",
            "path": "notices.json",
            "directory": "output",
            "maxVariation": 0,
            "overwrite": "false"
          }
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/status').then((r) => r.text());",
            "output": "OK"
          }
        },
        {
          "runBrowserScript": "return document.title;"
        }
      ]
    }
  ]
}
```

#### 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: http-mock-request
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/invoices*"
          method: GET
          response:
            statusCode: 200
            headers:
              x-mock: docs
            bodyPath: invoices.json
      - mockRequest:
          url: http://localhost:8092/api/invoices
          method: POST
          response:
            statusCode: 201
            body:
              id: inv-2
      - mockRequest:
          url: "**/api/notices"
          response:
            body:
              - Invoices are due on the 3rd of each month.
      - mockRequest:
          url: "**/api/status"
          response:
            body: OK
      - goTo: http://localhost:8092/
      - runBrowserScript:
          surface: chrome
          script: return fetch(arguments[0]).then(async (r) => r.headers.get('x-mock') + ' ' + JSON.stringify(await r.json()));
          args:
            - /api/invoices?page=1
          output: /^docs .*inv-1/
          timeout: 10000
      - runBrowserScript:
          script: "return fetch('/api/invoices', { method: 'POST' }).then(async (r) => r.status + ' ' + (await r.json()).id);"
          output: 201 inv-2
      - runBrowserScript:
          surface:
            browser: chrome
          script: return fetch('/api/notices').then((r) => r.json());
          output: due on the 3rd
          path: notices.json
          directory: output
          maxVariation: 0
          overwrite: "false"
      - runBrowserScript:
          script: return fetch('/api/status').then((r) => r.text());
          output: OK
      - runBrowserScript: return document.title;
```

### Notes

* Only Chrome can stub requests, so the test's [`runOn`](/reference/schemas/test) runs it on headless Chrome on macOS and Linux. On a Windows CI runner, page loads with request stubs can stop responding, so the example leaves Windows out. In another browser, `mockRequest` is skipped.
* The `GET` stub's `url` is a glob, so it also matches the query string. The `POST` stub's `url` is the whole URL, so it matches only that address.
* A stub's `response.body` can be an object or array, sent as JSON, or a string, sent as is. The `POST` stub sends an object, the notices stub an array, and the status stub a string.
* `surface` picks the browser tab a script runs in, by engine name such as `chrome`, or as an object such as `{"browser": "chrome"}`. Without it, the script runs in the active tab.
* The notices step saves the script's return value to `output/notices.json` and compares later runs to it. With `maxVariation` at `0` and `overwrite` set to `false`, any change returns a warning and leaves the file as is.
* A `runBrowserScript` step's `output` checks the script's return value. The first script returns the stub's `x-mock` header and body, and `/^docs .*inv-1/` is a regular expression that matches both.
* Detection finds no steps here. The site's address is inline code rather than a link, so each variant opens it with a `goTo` statement.

## Run shell commands

This procedure uses [`runShell`](/docs/actions/runshell) as a command string and as an object with `command`, `args`, `stdio`, `shell`, `exitCodes`, `timeout`, `workingDirectory`, `path`, `directory`, `maxVariation`, `overwrite`, and `background` with `name` and `waitUntil`. The example's own config sets the default [`shell`](/reference/schemas/config) for its detected run. A [`closeSurface`](/docs/actions/closesurface) step stops the background process. See the [`runShell`](/reference/schemas/runshell) reference.

#### Prose

#### Markdown

**`prose.md`**

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

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

Stop the preview process when you're done.
````

#### MDX

**`prose.mdx`**

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

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

Stop the preview process when you're done.
````

#### AsciiDoc

**`prose.adoc`**

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

Print the Node.js version. The output starts with `v` and the major version:

[source,shell]
----
node --version
----

Confirm that Node.js runs a script:

[source,shell]
----
node -e "console.log('ready')"
----

A script that calls `process.exit(1)` exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----

Start a preview process, and wait until it prints `Preview ready`:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

Stop the preview process when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js setup</title></head>
<body>
<h1>Check your Node.js setup</h1>
<p>Print the Node.js version. The output starts with <code>v</code> and the major version:</p>
<pre><code class="language-shell">node --version</code></pre>
<p>Confirm that Node.js runs a script:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<p>A script that calls <code>process.exit(1)</code> exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
<p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <code>folder-name.txt</code>:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
<p>Start a preview process, and wait until it prints <code>Preview ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<p>Stop the preview process when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

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

Print the Node.js version. The output starts with ``v`` and the major version:

.. code-block:: shell

   node --version

Confirm that Node.js runs a script:

.. code-block:: shell

   node -e "console.log('ready')"

A script that calls ``process.exit(1)`` exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"

From the folder that holds this page, print the folder's name. The output matches the saved copy in ``folder-name.txt``:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"

Start a preview process, and wait until it prints ``Preview ready``:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

Stop the preview process when you're done.
```

#### 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="http-run-shell">
  <title>Check your Node.js setup</title>
  <body>
    <p>Print the Node.js version. The output starts with <codeph>v</codeph> and the major version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <p>Confirm that Node.js runs a script:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <p>A script that calls <codeph>process.exit(1)</codeph> exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
    <p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <codeph>folder-name.txt</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
    <p>Start a preview process, and wait until it prints <codeph>Preview ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <p>Stop the preview process when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-run-shell","detectSteps":true} -->

# Check your Node.js setup

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

<!-- step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} -->

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

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

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} -->

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} -->

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} -->

Stop the preview process when you're done.

<!-- step {"closeSurface":"http-shell-preview"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-run-shell","detectSteps":true} */}

# Check your Node.js setup

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

{/* step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} */}

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

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

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

{/* step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} */}

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

{/* step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} */}

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} */}

Stop the preview process when you're done.

{/* step {"closeSurface":"http-shell-preview"} */}

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

#### AsciiDoc

**`detected.adoc`**

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

// (test {"testId":"http-run-shell","detectSteps":true})

Print the Node.js version. The output starts with `v` and the major version:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}})

Confirm that Node.js runs a script:

[source,shell]
----
node -e "console.log('ready')"
----

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

A script that calls `process.exit(1)` exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----

// (step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}})

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----

// (step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}})

Start a preview process, and wait until it prints `Preview ready`:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}})

Stop the preview process when you're done.

// (step {"closeSurface":"http-shell-preview"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js setup</title></head>
<body>
<!-- test {"testId":"http-run-shell","detectSteps":true} -->
<h1>Check your Node.js setup</h1>
<p>Print the Node.js version. The output starts with <code>v</code> and the major version:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} -->
<p>Confirm that Node.js runs a script:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":"node -e \"console.log('ready')\""} -->
<p>A script that calls <code>process.exit(1)</code> exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} -->
<p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <code>folder-name.txt</code>:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} -->
<p>Start a preview process, and wait until it prints <code>Preview ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} -->
<p>Stop the preview process when you're done.</p>
<!-- step {"closeSurface":"http-shell-preview"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

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

.. test {"testId":"http-run-shell","detectSteps":true}

Print the Node.js version. The output starts with ``v`` and the major version:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}}

Confirm that Node.js runs a script:

.. code-block:: shell

   node -e "console.log('ready')"

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

A script that calls ``process.exit(1)`` exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"

.. step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}}

From the folder that holds this page, print the folder's name. The output matches the saved copy in ``folder-name.txt``:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"

.. step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}}

Start a preview process, and wait until it prints ``Preview ready``:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}}

Stop the preview process when you're done.

.. step {"closeSurface":"http-shell-preview"}

.. 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="http-run-shell">
  <title>Check your Node.js setup</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-run-shell","detectSteps":true}'/>
    <p>Print the Node.js version. The output starts with <codeph>v</codeph> and the major version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}}'/>
    <p>Confirm that Node.js runs a script:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;ready&apos;)\""}'/>
    <p>A script that calls <codeph>process.exit(1)</codeph> exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}}'/>
    <p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <codeph>folder-name.txt</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(require(&apos;path&apos;).basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}}'/>
    <p>Start a preview process, and wait until it prints <codeph>Preview ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Preview ready&apos;); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}}'/>
    <p>Stop the preview process when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-preview"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-run-shell","detectSteps":false} -->

# Check your Node.js setup

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

<!-- step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} -->

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

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

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} -->

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} -->

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} -->

Stop the preview process when you're done.

<!-- step {"closeSurface":"http-shell-preview"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-run-shell","detectSteps":false} */}

# Check your Node.js setup

Print the Node.js version. The output starts with `v` and the major version:

```shell
node --version
```

{/* step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} */}

Confirm that Node.js runs a script:

```shell
node -e "console.log('ready')"
```

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

A script that calls `process.exit(1)` exits with code `1`:

```shell
node -e "process.exit(1)"
```

{/* step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} */}

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

{/* step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} */}

Start a preview process, and wait until it prints `Preview ready`:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} */}

Stop the preview process when you're done.

{/* step {"closeSurface":"http-shell-preview"} */}

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

#### AsciiDoc

**`inline.adoc`**

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

// (test {"testId":"http-run-shell","detectSteps":false})

Print the Node.js version. The output starts with `v` and the major version:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}})

Confirm that Node.js runs a script:

[source,shell]
----
node -e "console.log('ready')"
----

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

A script that calls `process.exit(1)` exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----

// (step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}})

From the folder that holds this page, print the folder's name. The output matches the saved copy in `folder-name.txt`:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----

// (step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}})

Start a preview process, and wait until it prints `Preview ready`:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}})

Stop the preview process when you're done.

// (step {"closeSurface":"http-shell-preview"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check your Node.js setup</title></head>
<body>
<!-- test {"testId":"http-run-shell","detectSteps":false} -->
<h1>Check your Node.js setup</h1>
<p>Print the Node.js version. The output starts with <code>v</code> and the major version:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}} -->
<p>Confirm that Node.js runs a script:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":"node -e \"console.log('ready')\""} -->
<p>A script that calls <code>process.exit(1)</code> exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}} -->
<p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <code>folder-name.txt</code>:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}} -->
<p>Start a preview process, and wait until it prints <code>Preview ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}} -->
<p>Stop the preview process when you're done.</p>
<!-- step {"closeSurface":"http-shell-preview"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

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

.. test {"testId":"http-run-shell","detectSteps":false}

Print the Node.js version. The output starts with ``v`` and the major version:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}}

Confirm that Node.js runs a script:

.. code-block:: shell

   node -e "console.log('ready')"

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

A script that calls ``process.exit(1)`` exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"

.. step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}}

From the folder that holds this page, print the folder's name. The output matches the saved copy in ``folder-name.txt``:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"

.. step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}}

Start a preview process, and wait until it prints ``Preview ready``:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}}

Stop the preview process when you're done.

.. step {"closeSurface":"http-shell-preview"}

.. 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="http-run-shell">
  <title>Check your Node.js setup</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-run-shell","detectSteps":false}'/>
    <p>Print the Node.js version. The output starts with <codeph>v</codeph> and the major version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node","args":["--version"],"stdio":"/^v\\d+\\./"}}'/>
    <p>Confirm that Node.js runs a script:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;ready&apos;)\""}'/>
    <p>A script that calls <codeph>process.exit(1)</codeph> exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"process.exit(1)\"","shell":"bash","exitCodes":[1],"timeout":10000}}'/>
    <p>From the folder that holds this page, print the folder's name. The output matches the saved copy in <codeph>folder-name.txt</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(require(&apos;path&apos;).basename(process.cwd()))\"","workingDirectory":".","stdio":"http-run-shell","path":"folder-name.txt","directory":"output","maxVariation":0.1,"overwrite":"aboveVariation"}}'/>
    <p>Start a preview process, and wait until it prints <codeph>Preview ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Preview ready&apos;); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-preview","waitUntil":{"stdio":"Preview ready","delayMs":250}},"timeout":15000}}'/>
    <p>Stop the preview process when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-preview"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-run-shell",
      "steps": [
        {
          "runShell": {
            "command": "node",
            "args": [
              "--version"
            ],
            "stdio": "/^v\\d+\\./"
          }
        },
        {
          "runShell": "node -e \"console.log('ready')\""
        },
        {
          "runShell": {
            "command": "node -e \"process.exit(1)\"",
            "shell": "bash",
            "exitCodes": [
              1
            ],
            "timeout": 10000
          }
        },
        {
          "runShell": {
            "command": "node -e \"console.log(require('path').basename(process.cwd()))\"",
            "workingDirectory": ".",
            "stdio": "http-run-shell",
            "path": "folder-name.txt",
            "directory": "output",
            "maxVariation": 0.1,
            "overwrite": "aboveVariation"
          }
        },
        {
          "runShell": {
            "command": "node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"",
            "background": {
              "name": "http-shell-preview",
              "waitUntil": {
                "stdio": "Preview ready",
                "delayMs": 250
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-shell-preview"
        }
      ]
    }
  ]
}
```

#### 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: http-run-shell
    steps:
      - runShell:
          command: node
          args:
            - --version
          stdio: /^v\d+\./
      - runShell: node -e "console.log('ready')"
      - runShell:
          command: node -e "process.exit(1)"
          shell: bash
          exitCodes:
            - 1
          timeout: 10000
      - runShell:
          command: node -e "console.log(require('path').basename(process.cwd()))"
          workingDirectory: .
          stdio: http-run-shell
          path: folder-name.txt
          directory: output
          maxVariation: 0.1
          overwrite: aboveVariation
      - runShell:
          command: node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
          background:
            name: http-shell-preview
            waitUntil:
              stdio: Preview ready
              delayMs: 250
          timeout: 15000
      - closeSurface: http-shell-preview
```

### Notes

* Default detection runs code blocks tagged `bash`, `python`, `py`, `javascript`, or `js` with `runCode`. These blocks are tagged `shell`, so detection skips them, and each variant carries its `runShell` steps in statements.

* Every command runs in Bash, the default shell on every platform. On Windows, Doc Detective uses Git Bash. The third step names it with `shell`, and the detected run's `doc-detective.json` sets it for every step:

  **`doc-detective.json`**

  ```json title="doc-detective.json"
  {
    "detectSteps": true,
    "shell": "bash"
  }
  ```

* Each command runs `node -e`, so the procedure works wherever Node.js does.

* `stdio` accepts a string or a regular expression between slashes, such as `/^v\d+\./`.

* The fourth step sets `workingDirectory` to `.`, the folder that holds the test file, and saves its output to `folder-name.txt` in the `output` folder there.

* The fifth step starts a background process and returns once the process prints `Preview ready` and 250 milliseconds pass. Its `timeout` limits how long it waits for both.

## Check files a command writes

This procedure writes a file with [`runShell`](/docs/actions/runshell), then checks it with [`checkFile`](/docs/actions/checkfile) as a glob string and as an object with `path`, `content`, and `timeout`. See the [`checkFile`](/reference/schemas/checkfile) reference.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

Check that the `output` folder holds a text file.

Check that the report says the build passed.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

Check that the `output` folder holds a text file.

Check that the report says the build passed.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check a build report

Write the build report to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
----

Check that the `output` folder holds a text file.

Check that the report says the build passed.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a build report</title></head>
<body>
<h1>Check a build report</h1>
<p>Write the build report to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</code></pre>
<p>Check that the <code>output</code> folder holds a text file.</p>
<p>Check that the report says the build passed.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check a build report
====================

Write the build report to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"

Check that the ``output`` folder holds a text file.

Check that the report says the build passed.
```

#### 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="http-checkfile">
  <title>Check a build report</title>
  <body>
    <p>Write the build report to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</codeblock>
    <p>Check that the <codeph>output</codeph> folder holds a text file.</p>
    <p>Check that the report says the build passed.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} -->

Check that the `output` folder holds a text file.

<!-- step {"checkFile":"output/*.txt"} -->

Check that the report says the build passed.

<!-- step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile","detectSteps":true} */}

# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} */}

Check that the `output` folder holds a text file.

{/* step {"checkFile":"output/*.txt"} */}

Check that the report says the build passed.

{/* step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check a build report

// (test {"testId":"http-checkfile","detectSteps":true})

Write the build report to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}})

Check that the `output` folder holds a text file.

// (step {"checkFile":"output/*.txt"})

Check that the report says the build passed.

// (step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a build report</title></head>
<body>
<!-- test {"testId":"http-checkfile","detectSteps":true} -->
<h1>Check a build report</h1>
<p>Write the build report to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} -->
<p>Check that the <code>output</code> folder holds a text file.</p>
<!-- step {"checkFile":"output/*.txt"} -->
<p>Check that the report says the build passed.</p>
<!-- step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check a build report
====================

.. test {"testId":"http-checkfile","detectSteps":true}

Write the build report to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}}

Check that the ``output`` folder holds a text file.

.. step {"checkFile":"output/*.txt"}

Check that the report says the build passed.

.. step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}}

.. 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="http-checkfile">
  <title>Check a build report</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile","detectSteps":true}'/>
    <p>Write the build report to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/report.txt&apos;,&apos;build 7 passed&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the <codeph>output</codeph> folder holds a text file.</p>
    <data name="doc-detective" value='step {"checkFile":"output/*.txt"}'/>
    <p>Check that the report says the build passed.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} -->

Check that the `output` folder holds a text file.

<!-- step {"checkFile":"output/*.txt"} -->

Check that the report says the build passed.

<!-- step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile","detectSteps":false} */}

# Check a build report

Write the build report to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} */}

Check that the `output` folder holds a text file.

{/* step {"checkFile":"output/*.txt"} */}

Check that the report says the build passed.

{/* step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check a build report

// (test {"testId":"http-checkfile","detectSteps":false})

Write the build report to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}})

Check that the `output` folder holds a text file.

// (step {"checkFile":"output/*.txt"})

Check that the report says the build passed.

// (step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a build report</title></head>
<body>
<!-- test {"testId":"http-checkfile","detectSteps":false} -->
<h1>Check a build report</h1>
<p>Write the build report to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}} -->
<p>Check that the <code>output</code> folder holds a text file.</p>
<!-- step {"checkFile":"output/*.txt"} -->
<p>Check that the report says the build passed.</p>
<!-- step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check a build report
====================

.. test {"testId":"http-checkfile","detectSteps":false}

Write the build report to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"","workingDirectory":"."}}

Check that the ``output`` folder holds a text file.

.. step {"checkFile":"output/*.txt"}

Check that the report says the build passed.

.. step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}}

.. 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="http-checkfile">
  <title>Check a build report</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile","detectSteps":false}'/>
    <p>Write the build report to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/report.txt&apos;,&apos;build 7 passed&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the <codeph>output</codeph> folder holds a text file.</p>
    <data name="doc-detective" value='step {"checkFile":"output/*.txt"}'/>
    <p>Check that the report says the build passed.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/report.txt","content":"/build [0-9]+ passed/","timeout":10000}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')\"",
            "workingDirectory": "."
          }
        },
        {
          "checkFile": "output/*.txt"
        },
        {
          "checkFile": {
            "path": "output/report.txt",
            "content": "/build [0-9]+ passed/",
            "timeout": 10000
          }
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/report.txt','build 7 passed')"
          workingDirectory: .
      - checkFile: output/*.txt
      - checkFile:
          path: output/report.txt
          content: /build [0-9]+ passed/
          timeout: 10000
```

### Notes

* Detection finds no steps here. The code block is tagged `shell`, and no detection rule makes a `checkFile` step, so each variant carries its steps in statements.
* The command runs in the folder that holds the test file. A relative `checkFile` path resolves against that file, so both point at the same `output` folder.
* A `content` value between slashes, such as `/build [0-9]+ passed/`, is a regular expression.

## `checkFile` permutations

### `checkFile` as a string

**Varies:** `checkFile` · **Value:** `"output/notes.txt"` · **Effect:** waits for the file, with a relative path resolved against the test file.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

Check that `output/notes.txt` exists.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

Check that `output/notes.txt` exists.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check that a file exists

Write the release notes to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
----

Check that `output/notes.txt` exists.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check that a file exists</title></head>
<body>
<h1>Check that a file exists</h1>
<p>Write the release notes to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</code></pre>
<p>Check that <code>output/notes.txt</code> exists.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check that a file exists
========================

Write the release notes to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"

Check that ``output/notes.txt`` exists.
```

#### 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="http-checkfile-string">
  <title>Check that a file exists</title>
  <body>
    <p>Write the release notes to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</codeblock>
    <p>Check that <codeph>output/notes.txt</codeph> exists.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-checkfile-string","detectSteps":true} -->

# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} -->

Check that `output/notes.txt` exists.

<!-- step {"checkFile":"output/notes.txt"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-string","detectSteps":true} */}

# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} */}

Check that `output/notes.txt` exists.

{/* step {"checkFile":"output/notes.txt"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check that a file exists

// (test {"testId":"http-checkfile-string","detectSteps":true})

Write the release notes to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}})

Check that `output/notes.txt` exists.

// (step {"checkFile":"output/notes.txt"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check that a file exists</title></head>
<body>
<!-- test {"testId":"http-checkfile-string","detectSteps":true} -->
<h1>Check that a file exists</h1>
<p>Write the release notes to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} -->
<p>Check that <code>output/notes.txt</code> exists.</p>
<!-- step {"checkFile":"output/notes.txt"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check that a file exists
========================

.. test {"testId":"http-checkfile-string","detectSteps":true}

Write the release notes to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}}

Check that ``output/notes.txt`` exists.

.. step {"checkFile":"output/notes.txt"}

.. 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="http-checkfile-string">
  <title>Check that a file exists</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-string","detectSteps":true}'/>
    <p>Write the release notes to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/notes.txt&apos;,&apos;release notes&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that <codeph>output/notes.txt</codeph> exists.</p>
    <data name="doc-detective" value='step {"checkFile":"output/notes.txt"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-checkfile-string","detectSteps":false} -->

# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} -->

Check that `output/notes.txt` exists.

<!-- step {"checkFile":"output/notes.txt"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-string","detectSteps":false} */}

# Check that a file exists

Write the release notes to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} */}

Check that `output/notes.txt` exists.

{/* step {"checkFile":"output/notes.txt"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check that a file exists

// (test {"testId":"http-checkfile-string","detectSteps":false})

Write the release notes to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}})

Check that `output/notes.txt` exists.

// (step {"checkFile":"output/notes.txt"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check that a file exists</title></head>
<body>
<!-- test {"testId":"http-checkfile-string","detectSteps":false} -->
<h1>Check that a file exists</h1>
<p>Write the release notes to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}} -->
<p>Check that <code>output/notes.txt</code> exists.</p>
<!-- step {"checkFile":"output/notes.txt"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check that a file exists
========================

.. test {"testId":"http-checkfile-string","detectSteps":false}

Write the release notes to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"","workingDirectory":"."}}

Check that ``output/notes.txt`` exists.

.. step {"checkFile":"output/notes.txt"}

.. 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="http-checkfile-string">
  <title>Check that a file exists</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-string","detectSteps":false}'/>
    <p>Write the release notes to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/notes.txt&apos;,&apos;release notes&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that <codeph>output/notes.txt</codeph> exists.</p>
    <data name="doc-detective" value='step {"checkFile":"output/notes.txt"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-string",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')\"",
            "workingDirectory": "."
          }
        },
        {
          "checkFile": "output/notes.txt"
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-string
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/notes.txt','release notes')"
          workingDirectory: .
      - checkFile: output/notes.txt
```

### `path` as a glob

**Varies:** `checkFile.path` · **Value:** `"output/*.log"` · **Effect:** waits for any matching file, and the newest finished match counts.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

Check that the `output` folder holds a log file.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

Check that the `output` folder holds a log file.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check for any log file

Write a log to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
----

Check that the `output` folder holds a log file.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check for any log file</title></head>
<body>
<h1>Check for any log file</h1>
<p>Write a log to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</code></pre>
<p>Check that the <code>output</code> folder holds a log file.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check for any log file
======================

Write a log to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"

Check that the ``output`` folder holds a log file.
```

#### 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="http-checkfile-path">
  <title>Check for any log file</title>
  <body>
    <p>Write a log to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</codeblock>
    <p>Check that the <codeph>output</codeph> folder holds a log file.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-checkfile-path","detectSteps":true} -->

# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} -->

Check that the `output` folder holds a log file.

<!-- step {"checkFile":{"path":"output/*.log"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-path","detectSteps":true} */}

# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} */}

Check that the `output` folder holds a log file.

{/* step {"checkFile":{"path":"output/*.log"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check for any log file

// (test {"testId":"http-checkfile-path","detectSteps":true})

Write a log to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}})

Check that the `output` folder holds a log file.

// (step {"checkFile":{"path":"output/*.log"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check for any log file</title></head>
<body>
<!-- test {"testId":"http-checkfile-path","detectSteps":true} -->
<h1>Check for any log file</h1>
<p>Write a log to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} -->
<p>Check that the <code>output</code> folder holds a log file.</p>
<!-- step {"checkFile":{"path":"output/*.log"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check for any log file
======================

.. test {"testId":"http-checkfile-path","detectSteps":true}

Write a log to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}}

Check that the ``output`` folder holds a log file.

.. step {"checkFile":{"path":"output/*.log"}}

.. 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="http-checkfile-path">
  <title>Check for any log file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-path","detectSteps":true}'/>
    <p>Write a log to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/app.log&apos;,&apos;started&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the <codeph>output</codeph> folder holds a log file.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/*.log"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-checkfile-path","detectSteps":false} -->

# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} -->

Check that the `output` folder holds a log file.

<!-- step {"checkFile":{"path":"output/*.log"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-path","detectSteps":false} */}

# Check for any log file

Write a log to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} */}

Check that the `output` folder holds a log file.

{/* step {"checkFile":{"path":"output/*.log"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check for any log file

// (test {"testId":"http-checkfile-path","detectSteps":false})

Write a log to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}})

Check that the `output` folder holds a log file.

// (step {"checkFile":{"path":"output/*.log"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check for any log file</title></head>
<body>
<!-- test {"testId":"http-checkfile-path","detectSteps":false} -->
<h1>Check for any log file</h1>
<p>Write a log to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}} -->
<p>Check that the <code>output</code> folder holds a log file.</p>
<!-- step {"checkFile":{"path":"output/*.log"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check for any log file
======================

.. test {"testId":"http-checkfile-path","detectSteps":false}

Write a log to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"","workingDirectory":"."}}

Check that the ``output`` folder holds a log file.

.. step {"checkFile":{"path":"output/*.log"}}

.. 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="http-checkfile-path">
  <title>Check for any log file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-path","detectSteps":false}'/>
    <p>Write a log to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/app.log&apos;,&apos;started&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the <codeph>output</codeph> folder holds a log file.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/*.log"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-path",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')\"",
            "workingDirectory": "."
          }
        },
        {
          "checkFile": {
            "path": "output/*.log"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-path
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/app.log','started')"
          workingDirectory: .
      - checkFile:
          path: output/*.log
```

### `content` as a string

**Varies:** `checkFile.content` · **Value:** `"succeeded"` · **Effect:** fails unless the file's text contains the string.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

Check that the status file says `succeeded`.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

Check that the status file says `succeeded`.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check a status file's text

Write the deploy status to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
----

Check that the status file says `succeeded`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a status file's text</title></head>
<body>
<h1>Check a status file's text</h1>
<p>Write the deploy status to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</code></pre>
<p>Check that the status file says <code>succeeded</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check a status file's text
==========================

Write the deploy status to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"

Check that the status file says ``succeeded``.
```

#### 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="http-checkfile-content-string">
  <title>Check a status file's text</title>
  <body>
    <p>Write the deploy status to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</codeblock>
    <p>Check that the status file says <codeph>succeeded</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-checkfile-content-string","detectSteps":true} -->

# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} -->

Check that the status file says `succeeded`.

<!-- step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-content-string","detectSteps":true} */}

# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} */}

Check that the status file says `succeeded`.

{/* step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check a status file's text

// (test {"testId":"http-checkfile-content-string","detectSteps":true})

Write the deploy status to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}})

Check that the status file says `succeeded`.

// (step {"checkFile":{"path":"output/status.txt","content":"succeeded"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a status file's text</title></head>
<body>
<!-- test {"testId":"http-checkfile-content-string","detectSteps":true} -->
<h1>Check a status file's text</h1>
<p>Write the deploy status to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} -->
<p>Check that the status file says <code>succeeded</code>.</p>
<!-- step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check a status file's text
==========================

.. test {"testId":"http-checkfile-content-string","detectSteps":true}

Write the deploy status to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}}

Check that the status file says ``succeeded``.

.. step {"checkFile":{"path":"output/status.txt","content":"succeeded"}}

.. 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="http-checkfile-content-string">
  <title>Check a status file's text</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-content-string","detectSteps":true}'/>
    <p>Write the deploy status to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/status.txt&apos;,&apos;deploy succeeded&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the status file says <codeph>succeeded</codeph>.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/status.txt","content":"succeeded"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-checkfile-content-string","detectSteps":false} -->

# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} -->

Check that the status file says `succeeded`.

<!-- step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-content-string","detectSteps":false} */}

# Check a status file's text

Write the deploy status to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} */}

Check that the status file says `succeeded`.

{/* step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check a status file's text

// (test {"testId":"http-checkfile-content-string","detectSteps":false})

Write the deploy status to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}})

Check that the status file says `succeeded`.

// (step {"checkFile":{"path":"output/status.txt","content":"succeeded"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check a status file's text</title></head>
<body>
<!-- test {"testId":"http-checkfile-content-string","detectSteps":false} -->
<h1>Check a status file's text</h1>
<p>Write the deploy status to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}} -->
<p>Check that the status file says <code>succeeded</code>.</p>
<!-- step {"checkFile":{"path":"output/status.txt","content":"succeeded"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check a status file's text
==========================

.. test {"testId":"http-checkfile-content-string","detectSteps":false}

Write the deploy status to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"","workingDirectory":"."}}

Check that the status file says ``succeeded``.

.. step {"checkFile":{"path":"output/status.txt","content":"succeeded"}}

.. 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="http-checkfile-content-string">
  <title>Check a status file's text</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-content-string","detectSteps":false}'/>
    <p>Write the deploy status to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/status.txt&apos;,&apos;deploy succeeded&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the status file says <codeph>succeeded</codeph>.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/status.txt","content":"succeeded"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-content-string",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')\"",
            "workingDirectory": "."
          }
        },
        {
          "checkFile": {
            "path": "output/status.txt",
            "content": "succeeded"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-content-string
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/status.txt','deploy succeeded')"
          workingDirectory: .
      - checkFile:
          path: output/status.txt
          content: succeeded
```

### `content` as a regular expression

**Varies:** `checkFile.content` · **Value:** `"/build [0-9]+ passed/"` · **Effect:** fails unless the file's text matches the regular expression.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

Check that the result names a passing build.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

Check that the result names a passing build.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Match a build number in a file

Write the build result to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
----

Check that the result names a passing build.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match a build number in a file</title></head>
<body>
<h1>Match a build number in a file</h1>
<p>Write the build result to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</code></pre>
<p>Check that the result names a passing build.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Match a build number in a file
==============================

Write the build result to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"

Check that the result names a passing build.
```

#### 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="http-checkfile-content-regex">
  <title>Match a build number in a file</title>
  <body>
    <p>Write the build result to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</codeblock>
    <p>Check that the result names a passing build.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-checkfile-content-regex","detectSteps":true} -->

# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} -->

Check that the result names a passing build.

<!-- step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-content-regex","detectSteps":true} */}

# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} */}

Check that the result names a passing build.

{/* step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Match a build number in a file

// (test {"testId":"http-checkfile-content-regex","detectSteps":true})

Write the build result to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}})

Check that the result names a passing build.

// (step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match a build number in a file</title></head>
<body>
<!-- test {"testId":"http-checkfile-content-regex","detectSteps":true} -->
<h1>Match a build number in a file</h1>
<p>Write the build result to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} -->
<p>Check that the result names a passing build.</p>
<!-- step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Match a build number in a file
==============================

.. test {"testId":"http-checkfile-content-regex","detectSteps":true}

Write the build result to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}}

Check that the result names a passing build.

.. step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}}

.. 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="http-checkfile-content-regex">
  <title>Match a build number in a file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-content-regex","detectSteps":true}'/>
    <p>Write the build result to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/build.txt&apos;,&apos;build 42 passed&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the result names a passing build.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-checkfile-content-regex","detectSteps":false} -->

# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} -->

Check that the result names a passing build.

<!-- step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-content-regex","detectSteps":false} */}

# Match a build number in a file

Write the build result to the `output` folder next to this page:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} */}

Check that the result names a passing build.

{/* step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Match a build number in a file

// (test {"testId":"http-checkfile-content-regex","detectSteps":false})

Write the build result to the `output` folder next to this page:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}})

Check that the result names a passing build.

// (step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match a build number in a file</title></head>
<body>
<!-- test {"testId":"http-checkfile-content-regex","detectSteps":false} -->
<h1>Match a build number in a file</h1>
<p>Write the build result to the <code>output</code> folder next to this page:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}} -->
<p>Check that the result names a passing build.</p>
<!-- step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Match a build number in a file
==============================

.. test {"testId":"http-checkfile-content-regex","detectSteps":false}

Write the build result to the ``output`` folder next to this page:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"","workingDirectory":"."}}

Check that the result names a passing build.

.. step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}}

.. 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="http-checkfile-content-regex">
  <title>Match a build number in a file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-content-regex","detectSteps":false}'/>
    <p>Write the build result to the <codeph>output</codeph> folder next to this page:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});fs.writeFileSync(&apos;output/build.txt&apos;,&apos;build 42 passed&apos;)\"","workingDirectory":"."}}'/>
    <p>Check that the result names a passing build.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/build.txt","content":"/build [0-9]+ passed/"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-content-regex",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')\"",
            "workingDirectory": "."
          }
        },
        {
          "checkFile": {
            "path": "output/build.txt",
            "content": "/build [0-9]+ passed/"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-content-regex
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});fs.writeFileSync('output/build.txt','build 42 passed')"
          workingDirectory: .
      - checkFile:
          path: output/build.txt
          content: /build [0-9]+ passed/
```

### `timeout: 15000`

**Varies:** `checkFile.timeout` · **Value:** `15000` · **Effect:** waits up to 15 seconds for a background job to write the file, instead of the default 30 seconds.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

Wait up to 15 seconds for `output/late.txt`.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

Wait up to 15 seconds for `output/late.txt`.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
----

Wait up to 15 seconds for `output/late.txt`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Wait for a slow file</title></head>
<body>
<h1>Wait for a slow file</h1>
<p>Start a job that writes its result to the <code>output</code> folder after one second:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</code></pre>
<p>Wait up to 15 seconds for <code>output/late.txt</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Wait for a slow file
====================

Start a job that writes its result to the ``output`` folder after one second:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"

Wait up to 15 seconds for ``output/late.txt``.
```

#### 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="http-checkfile-timeout">
  <title>Wait for a slow file</title>
  <body>
    <p>Start a job that writes its result to the <codeph>output</codeph> folder after one second:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</codeblock>
    <p>Wait up to 15 seconds for <codeph>output/late.txt</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-checkfile-timeout","detectSteps":true} -->

# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} -->

Wait up to 15 seconds for `output/late.txt`.

<!-- step {"checkFile":{"path":"output/late.txt","timeout":15000}} -->

<!-- step {"closeSurface":"late-writer"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-timeout","detectSteps":true} */}

# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} */}

Wait up to 15 seconds for `output/late.txt`.

{/* step {"checkFile":{"path":"output/late.txt","timeout":15000}} */}

{/* step {"closeSurface":"late-writer"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Wait for a slow file

// (test {"testId":"http-checkfile-timeout","detectSteps":true})

Start a job that writes its result to the `output` folder after one second:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}})

Wait up to 15 seconds for `output/late.txt`.

// (step {"checkFile":{"path":"output/late.txt","timeout":15000}})

// (step {"closeSurface":"late-writer"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Wait for a slow file</title></head>
<body>
<!-- test {"testId":"http-checkfile-timeout","detectSteps":true} -->
<h1>Wait for a slow file</h1>
<p>Start a job that writes its result to the <code>output</code> folder after one second:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} -->
<p>Wait up to 15 seconds for <code>output/late.txt</code>.</p>
<!-- step {"checkFile":{"path":"output/late.txt","timeout":15000}} -->

<!-- step {"closeSurface":"late-writer"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Wait for a slow file
====================

.. test {"testId":"http-checkfile-timeout","detectSteps":true}

Start a job that writes its result to the ``output`` folder after one second:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}}

Wait up to 15 seconds for ``output/late.txt``.

.. step {"checkFile":{"path":"output/late.txt","timeout":15000}}

.. step {"closeSurface":"late-writer"}

.. 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="http-checkfile-timeout">
  <title>Wait for a slow file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-timeout","detectSteps":true}'/>
    <p>Start a job that writes its result to the <codeph>output</codeph> folder after one second:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});setTimeout(()=>fs.writeFileSync(&apos;output/late.txt&apos;,&apos;done&apos;),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}}'/>
    <p>Wait up to 15 seconds for <codeph>output/late.txt</codeph>.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/late.txt","timeout":15000}}'/>
    <data name="doc-detective" value='step {"closeSurface":"late-writer"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-checkfile-timeout","detectSteps":false} -->

# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} -->

Wait up to 15 seconds for `output/late.txt`.

<!-- step {"checkFile":{"path":"output/late.txt","timeout":15000}} -->

<!-- step {"closeSurface":"late-writer"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-timeout","detectSteps":false} */}

# Wait for a slow file

Start a job that writes its result to the `output` folder after one second:

```shell
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
```

{/* step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} */}

Wait up to 15 seconds for `output/late.txt`.

{/* step {"checkFile":{"path":"output/late.txt","timeout":15000}} */}

{/* step {"closeSurface":"late-writer"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Wait for a slow file

// (test {"testId":"http-checkfile-timeout","detectSteps":false})

Start a job that writes its result to the `output` folder after one second:

[source,shell]
----
node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
----

// (step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}})

Wait up to 15 seconds for `output/late.txt`.

// (step {"checkFile":{"path":"output/late.txt","timeout":15000}})

// (step {"closeSurface":"late-writer"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Wait for a slow file</title></head>
<body>
<!-- test {"testId":"http-checkfile-timeout","detectSteps":false} -->
<h1>Wait for a slow file</h1>
<p>Start a job that writes its result to the <code>output</code> folder after one second:</p>
<pre><code class="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}} -->
<p>Wait up to 15 seconds for <code>output/late.txt</code>.</p>
<!-- step {"checkFile":{"path":"output/late.txt","timeout":15000}} -->

<!-- step {"closeSurface":"late-writer"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Wait for a slow file
====================

.. test {"testId":"http-checkfile-timeout","detectSteps":false}

Start a job that writes its result to the ``output`` folder after one second:

.. code-block:: shell

   node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"

.. step {"runShell":{"command":"node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}}

Wait up to 15 seconds for ``output/late.txt``.

.. step {"checkFile":{"path":"output/late.txt","timeout":15000}}

.. step {"closeSurface":"late-writer"}

.. 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="http-checkfile-timeout">
  <title>Wait for a slow file</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-timeout","detectSteps":false}'/>
    <p>Start a job that writes its result to the <codeph>output</codeph> folder after one second:</p>
    <codeblock outputclass="language-shell">node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=&gt;fs.writeFileSync('output/late.txt','done'),1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"const fs=require(&apos;fs&apos;);fs.mkdirSync(&apos;output&apos;,{recursive:true});setTimeout(()=>fs.writeFileSync(&apos;output/late.txt&apos;,&apos;done&apos;),1000)\"","workingDirectory":".","background":{"name":"late-writer"}}}'/>
    <p>Wait up to 15 seconds for <codeph>output/late.txt</codeph>.</p>
    <data name="doc-detective" value='step {"checkFile":{"path":"output/late.txt","timeout":15000}}'/>
    <data name="doc-detective" value='step {"closeSurface":"late-writer"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-timeout",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)\"",
            "workingDirectory": ".",
            "background": {
              "name": "late-writer"
            }
          }
        },
        {
          "checkFile": {
            "path": "output/late.txt",
            "timeout": 15000
          }
        },
        {
          "closeSurface": "late-writer"
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-timeout
    steps:
      - runShell:
          command: node -e "const fs=require('fs');fs.mkdirSync('output',{recursive:true});setTimeout(()=>fs.writeFileSync('output/late.txt','done'),1000)"
          workingDirectory: .
          background:
            name: late-writer
      - checkFile:
          path: output/late.txt
          timeout: 15000
      - closeSurface: late-writer
```

### `download`

**Varies:** `checkFile.download` · **Value:** `"report-*.csv"` · **Effect:** waits for a browser download in the context's download folder, so it needs an earlier step to open Chrome or Firefox.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Download a report

In Chrome, open `http://localhost:8092/download.html`.

Click the first export link.

Check that Chrome saved a `report-*.csv` file.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Download a report

In Chrome, open `http://localhost:8092/download.html`.

Click the first export link.

Check that Chrome saved a `report-*.csv` file.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Download a report

In Chrome, open `http://localhost:8092/download.html`.

Click the first export link.

Check that Chrome saved a `report-*.csv` file.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Download a report</title></head>
<body>
<h1>Download a report</h1>
<p>In Chrome, open <code>http://localhost:8092/download.html</code>.</p>
<p>Click the first export link.</p>
<p>Check that Chrome saved a <code>report-*.csv</code> file.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Download a report
=================

In Chrome, open ``http://localhost:8092/download.html``.

Click the first export link.

Check that Chrome saved a ``report-*.csv`` file.
```

#### 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="http-checkfile-download">
  <title>Download a report</title>
  <body>
    <p>In Chrome, open <codeph>http://localhost:8092/download.html</codeph>.</p>
    <p>Click the first export link.</p>
    <p>Check that Chrome saved a <codeph>report-*.csv</codeph> file.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Download a report

In Chrome, open `http://localhost:8092/download.html`.

<!-- step {"goTo":"http://localhost:8092/download.html"} -->

Click the first export link.

<!-- step {"click":"Export first CSV"} -->

Check that Chrome saved a `report-*.csv` file.

<!-- step {"checkFile":{"download":"report-*.csv"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Download a report

In Chrome, open `http://localhost:8092/download.html`.

{/* step {"goTo":"http://localhost:8092/download.html"} */}

Click the first export link.

{/* step {"click":"Export first CSV"} */}

Check that Chrome saved a `report-*.csv` file.

{/* step {"checkFile":{"download":"report-*.csv"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Download a report

// (test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

In Chrome, open `http://localhost:8092/download.html`.

// (step {"goTo":"http://localhost:8092/download.html"})

Click the first export link.

// (step {"click":"Export first CSV"})

Check that Chrome saved a `report-*.csv` file.

// (step {"checkFile":{"download":"report-*.csv"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Download a report</title></head>
<body>
<!-- test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Download a report</h1>
<p>In Chrome, open <code>http://localhost:8092/download.html</code>.</p>
<!-- step {"goTo":"http://localhost:8092/download.html"} -->
<p>Click the first export link.</p>
<!-- step {"click":"Export first CSV"} -->
<p>Check that Chrome saved a <code>report-*.csv</code> file.</p>
<!-- step {"checkFile":{"download":"report-*.csv"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Download a report
=================

.. test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

In Chrome, open ``http://localhost:8092/download.html``.

.. step {"goTo":"http://localhost:8092/download.html"}

Click the first export link.

.. step {"click":"Export first CSV"}

Check that Chrome saved a ``report-*.csv`` file.

.. step {"checkFile":{"download":"report-*.csv"}}

.. 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="http-checkfile-download">
  <title>Download a report</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-download","detectSteps":true,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>In Chrome, open <codeph>http://localhost:8092/download.html</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/download.html"}'/>
    <p>Click the first export link.</p>
    <data name="doc-detective" value='step {"click":"Export first CSV"}'/>
    <p>Check that Chrome saved a <codeph>report-*.csv</codeph> file.</p>
    <data name="doc-detective" value='step {"checkFile":{"download":"report-*.csv"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Download a report

In Chrome, open `http://localhost:8092/download.html`.

<!-- step {"goTo":"http://localhost:8092/download.html"} -->

Click the first export link.

<!-- step {"click":"Export first CSV"} -->

Check that Chrome saved a `report-*.csv` file.

<!-- step {"checkFile":{"download":"report-*.csv"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Download a report

In Chrome, open `http://localhost:8092/download.html`.

{/* step {"goTo":"http://localhost:8092/download.html"} */}

Click the first export link.

{/* step {"click":"Export first CSV"} */}

Check that Chrome saved a `report-*.csv` file.

{/* step {"checkFile":{"download":"report-*.csv"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Download a report

// (test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

In Chrome, open `http://localhost:8092/download.html`.

// (step {"goTo":"http://localhost:8092/download.html"})

Click the first export link.

// (step {"click":"Export first CSV"})

Check that Chrome saved a `report-*.csv` file.

// (step {"checkFile":{"download":"report-*.csv"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Download a report</title></head>
<body>
<!-- test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Download a report</h1>
<p>In Chrome, open <code>http://localhost:8092/download.html</code>.</p>
<!-- step {"goTo":"http://localhost:8092/download.html"} -->
<p>Click the first export link.</p>
<!-- step {"click":"Export first CSV"} -->
<p>Check that Chrome saved a <code>report-*.csv</code> file.</p>
<!-- step {"checkFile":{"download":"report-*.csv"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Download a report
=================

.. test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

In Chrome, open ``http://localhost:8092/download.html``.

.. step {"goTo":"http://localhost:8092/download.html"}

Click the first export link.

.. step {"click":"Export first CSV"}

Check that Chrome saved a ``report-*.csv`` file.

.. step {"checkFile":{"download":"report-*.csv"}}

.. 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="http-checkfile-download">
  <title>Download a report</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-checkfile-download","detectSteps":false,"runOn":[{"platforms":["windows","mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>In Chrome, open <codeph>http://localhost:8092/download.html</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/download.html"}'/>
    <p>Click the first export link.</p>
    <data name="doc-detective" value='step {"click":"Export first CSV"}'/>
    <p>Check that Chrome saved a <codeph>report-*.csv</codeph> file.</p>
    <data name="doc-detective" value='step {"checkFile":{"download":"report-*.csv"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-checkfile-download",
      "runOn": [
        {
          "platforms": [
            "windows",
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "goTo": "http://localhost:8092/download.html"
        },
        {
          "click": "Export first CSV"
        },
        {
          "checkFile": {
            "download": "report-*.csv"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-checkfile-download
    runOn:
      - platforms:
          - windows
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - goTo: http://localhost:8092/download.html
      - click: Export first CSV
      - checkFile:
          download: report-*.csv
```

The test's [`runOn`](/reference/schemas/test) runs it on headless Chrome on every platform. In Safari, or in a test with no browser, the `download` step is skipped.

## Run code blocks

This procedure uses [`runCode`](/docs/actions/runcode) with `language` set to `javascript`, `py`, and `bash`, along with `code`, `stdio`, `exitCodes`, `workingDirectory`, `timeout`, `path`, `directory`, `maxVariation`, and `overwrite`. `py` runs as `python`, and `js` runs as `javascript`. Default detection makes the same steps from the code blocks. See the [`runCode`](/reference/schemas/runcode) reference.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

Run the same greeting in Python:

```py
print("Hello from Python")
```

Or in Bash:

```bash
echo "Hello from Bash"
```

To install the greeter for every project on your machine, run:

```bash
npm install --global ./greeter
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

Run the same greeting in Python:

```py
print("Hello from Python")
```

Or in Bash:

```bash
echo "Hello from Bash"
```

To install the greeter for every project on your machine, run:

```bash
npm install --global ./greeter
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Print a greeting

Run this JavaScript with Node.js:

[source,javascript]
----
console.log("Hello from JavaScript");
----

Run the same greeting in Python:

[source,py]
----
print("Hello from Python")
----

Or in Bash:

[source,bash]
----
echo "Hello from Bash"
----

To install the greeter for every project on your machine, run:

[source,bash]
----
npm install --global ./greeter
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print a greeting</title></head>
<body>
<h1>Print a greeting</h1>
<p>Run this JavaScript with Node.js:</p>
<pre><code class="language-javascript">console.log("Hello from JavaScript");</code></pre>
<p>Run the same greeting in Python:</p>
<pre><code class="language-py">print("Hello from Python")</code></pre>
<p>Or in Bash:</p>
<pre><code class="language-bash">echo "Hello from Bash"</code></pre>
<p>To install the greeter for every project on your machine, run:</p>
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Print a greeting
================

Run this JavaScript with Node.js:

.. code-block:: javascript

   console.log("Hello from JavaScript");

Run the same greeting in Python:

.. code-block:: py

   print("Hello from Python")

Or in Bash:

.. code-block:: bash

   echo "Hello from Bash"

To install the greeter for every project on your machine, run:

.. code-block:: bash

   npm install --global ./greeter
```

#### 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="http-run-code">
  <title>Print a greeting</title>
  <body>
    <p>Run this JavaScript with Node.js:</p>
    <codeblock outputclass="language-javascript">console.log("Hello from JavaScript");</codeblock>
    <p>Run the same greeting in Python:</p>
    <codeblock outputclass="language-py">print("Hello from Python")</codeblock>
    <p>Or in Bash:</p>
    <codeblock outputclass="language-bash">echo "Hello from Bash"</codeblock>
    <p>To install the greeter for every project on your machine, run:</p>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-run-code","detectSteps":true} -->

# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

Run the same greeting in Python:

```py
print("Hello from Python")
```

Or in Bash:

```bash
echo "Hello from Bash"
```

To install the greeter for every project on your machine, run:

```bash testIgnore
npm install --global ./greeter
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-run-code","detectSteps":true} */}

# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

Run the same greeting in Python:

```py
print("Hello from Python")
```

Or in Bash:

```bash
echo "Hello from Bash"
```

To install the greeter for every project on your machine, run:

```bash testIgnore
npm install --global ./greeter
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Print a greeting

// (test {"testId":"http-run-code","detectSteps":true})

Run this JavaScript with Node.js:

[source,javascript]
----
console.log("Hello from JavaScript");
----

Run the same greeting in Python:

[source,py]
----
print("Hello from Python")
----

Or in Bash:

[source,bash]
----
echo "Hello from Bash"
----

To install the greeter for every project on your machine, run:

[source,bash,testIgnore]
----
npm install --global ./greeter
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print a greeting</title></head>
<body>
<!-- test {"testId":"http-run-code","detectSteps":true} -->
<h1>Print a greeting</h1>
<p>Run this JavaScript with Node.js:</p>
<pre><code class="language-javascript">console.log("Hello from JavaScript");</code></pre>
<p>Run the same greeting in Python:</p>
<pre><code class="language-py">print("Hello from Python")</code></pre>
<p>Or in Bash:</p>
<pre><code class="language-bash">echo "Hello from Bash"</code></pre>
<p>To install the greeter for every project on your machine, run:</p>
<!-- test ignore start -->
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
<!-- test ignore end -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Print a greeting
================

.. test {"testId":"http-run-code","detectSteps":true}

Run this JavaScript with Node.js:

.. code-block:: javascript

   console.log("Hello from JavaScript");

Run the same greeting in Python:

.. code-block:: py

   print("Hello from Python")

Or in Bash:

.. code-block:: bash

   echo "Hello from Bash"

To install the greeter for every project on your machine, run:

.. code-block:: bash
   :class: testIgnore

   npm install --global ./greeter

.. 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="http-run-code">
  <title>Print a greeting</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-run-code","detectSteps":true}'/>
    <p>Run this JavaScript with Node.js:</p>
    <codeblock outputclass="language-javascript">console.log("Hello from JavaScript");</codeblock>
    <p>Run the same greeting in Python:</p>
    <codeblock outputclass="language-py">print("Hello from Python")</codeblock>
    <p>Or in Bash:</p>
    <codeblock outputclass="language-bash">echo "Hello from Bash"</codeblock>
    <p>To install the greeter for every project on your machine, run:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-run-code","detectSteps":false} -->

# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

<!-- step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}} -->

Run the same greeting in Python:

```py
print("Hello from Python")
```

<!-- step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}} -->

Or in Bash:

```bash
echo "Hello from Bash"
```

<!-- step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}} -->

To install the greeter for every project on your machine, run:

```bash
npm install --global ./greeter
```

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-run-code","detectSteps":false} */}

# Print a greeting

Run this JavaScript with Node.js:

```javascript
console.log("Hello from JavaScript");
```

{/* step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}} */}

Run the same greeting in Python:

```py
print("Hello from Python")
```

{/* step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}} */}

Or in Bash:

```bash
echo "Hello from Bash"
```

{/* step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}} */}

To install the greeter for every project on your machine, run:

```bash
npm install --global ./greeter
```

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Print a greeting

// (test {"testId":"http-run-code","detectSteps":false})

Run this JavaScript with Node.js:

[source,javascript]
----
console.log("Hello from JavaScript");
----

// (step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}})

Run the same greeting in Python:

[source,py]
----
print("Hello from Python")
----

// (step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}})

Or in Bash:

[source,bash]
----
echo "Hello from Bash"
----

// (step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}})

To install the greeter for every project on your machine, run:

[source,bash]
----
npm install --global ./greeter
----

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Print a greeting</title></head>
<body>
<!-- test {"testId":"http-run-code","detectSteps":false} -->
<h1>Print a greeting</h1>
<p>Run this JavaScript with Node.js:</p>
<pre><code class="language-javascript">console.log("Hello from JavaScript");</code></pre>
<!-- step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}} -->
<p>Run the same greeting in Python:</p>
<pre><code class="language-py">print("Hello from Python")</code></pre>
<!-- step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}} -->
<p>Or in Bash:</p>
<pre><code class="language-bash">echo "Hello from Bash"</code></pre>
<!-- step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}} -->
<p>To install the greeter for every project on your machine, run:</p>
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Print a greeting
================

.. test {"testId":"http-run-code","detectSteps":false}

Run this JavaScript with Node.js:

.. code-block:: javascript

   console.log("Hello from JavaScript");

.. step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}}

Run the same greeting in Python:

.. code-block:: py

   print("Hello from Python")

.. step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}}

Or in Bash:

.. code-block:: bash

   echo "Hello from Bash"

.. step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}}

To install the greeter for every project on your machine, run:

.. code-block:: bash

   npm install --global ./greeter

.. 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="http-run-code">
  <title>Print a greeting</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-run-code","detectSteps":false}'/>
    <p>Run this JavaScript with Node.js:</p>
    <codeblock outputclass="language-javascript">console.log("Hello from JavaScript");</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"javascript","code":"console.log(\"Hello from JavaScript\");","stdio":"Hello from JavaScript","exitCodes":[0],"workingDirectory":".","timeout":10000,"path":"greeting.txt","directory":"output","maxVariation":0,"overwrite":"false"}}'/>
    <p>Run the same greeting in Python:</p>
    <codeblock outputclass="language-py">print("Hello from Python")</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"py","code":"print(\"Hello from Python\")","stdio":"/^Hello from Python/"}}'/>
    <p>Or in Bash:</p>
    <codeblock outputclass="language-bash">echo "Hello from Bash"</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"bash","code":"echo \"Hello from Bash\"","stdio":"Hello from Bash"}}'/>
    <p>To install the greeter for every project on your machine, run:</p>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-run-code",
      "steps": [
        {
          "runCode": {
            "language": "javascript",
            "code": "console.log(\"Hello from JavaScript\");",
            "stdio": "Hello from JavaScript",
            "exitCodes": [
              0
            ],
            "workingDirectory": ".",
            "timeout": 10000,
            "path": "greeting.txt",
            "directory": "output",
            "maxVariation": 0,
            "overwrite": "false"
          }
        },
        {
          "runCode": {
            "language": "py",
            "code": "print(\"Hello from Python\")",
            "stdio": "/^Hello from Python/"
          }
        },
        {
          "runCode": {
            "language": "bash",
            "code": "echo \"Hello from Bash\"",
            "stdio": "Hello from Bash"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-run-code
    steps:
      - runCode:
          language: javascript
          code: console.log("Hello from JavaScript");
          stdio: Hello from JavaScript
          exitCodes:
            - 0
          workingDirectory: .
          timeout: 10000
          path: greeting.txt
          directory: output
          maxVariation: 0
          overwrite: "false"
      - runCode:
          language: py
          code: print("Hello from Python")
          stdio: /^Hello from Python/
      - runCode:
          language: bash
          code: echo "Hello from Bash"
          stdio: Hello from Bash
```

### What detection finds

Default detection turns each code block tagged `javascript`, `py`, or `bash` into a `runCode` step, with the block's language and content. It marks each detected step `unsafe`, because the code runs on your machine. An unsafe step runs only when the config sets [`allowUnsafeSteps`](/reference/schemas/config) to `true`, or you pass `--allow-unsafe`. Otherwise, the step is skipped. So the detected variants run with this config:

**`doc-detective.json`**

```json title="doc-detective.json"
{
  "detectSteps": true,
  "allowUnsafeSteps": true
}
```

The detected steps don't check output, so they pass when the code exits with code `0`. The inline and standalone variants aren't unsafe, so they run without `allowUnsafeSteps`, and they check each block's output. The JavaScript step also saves its output to `greeting.txt` in the `output` folder, and compares later runs to it.

To keep a code block from running, mark it to be ignored. In Markdown, MDX, and AsciiDoc, add `testIgnore` after the language, as in ` ```bash testIgnore ` or `[source,bash,testIgnore]`. In reStructuredText, add `:class: testIgnore` to the directive. HTML and DITA code blocks have no place for it, so wrap the block in `test ignore start` and `test ignore end` statements. The inline variants turn detection off, so they don't need either.

## Start and stop local servers

This procedure starts background processes with [`runCode`](/docs/actions/runcode) and [`runShell`](/docs/actions/runshell), using `args` and a `background` object with `name`, `tty`, and `waitUntil` with `port`, `stdio`, `httpGet`, and `delayMs`. It checks a server with [`httpRequest`](/docs/actions/httprequest), whose `response.body` is a string, and stops each process with [`closeSurface`](/docs/actions/closesurface).

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

Stop the server when you're done.

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

Stop it the same way.

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

Stop that process too.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

Stop the server when you're done.

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

Stop it the same way.

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

Stop that process too.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

[source,js]
----
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
----

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

Stop the server when you're done.

To start a quick server from your shell instead, run:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
----

Stop it the same way.

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

[source,js]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

Stop that process too.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a local server</title></head>
<body>
<h1>Run a local server</h1>
<p>Start the sample API server. It takes the port as an argument and prints <code>Listening</code> when it's ready:</p>
<pre><code class="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</code></pre>
<p>Check the server's health endpoint at <code>http://localhost:8231/health</code>. It returns <code>ok</code>.</p>
<p>Stop the server when you're done.</p>
<p>To start a quick server from your shell instead, run:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</code></pre>
<p>Stop it the same way.</p>
<p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
<p>Stop that process too.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a local server
==================

Start the sample API server. It takes the port as an argument and prints ``Listening`` when it's ready:

.. code-block:: js

   const http = require("http");
   const port = Number(process.argv[2]);
   http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));

Check the server's health endpoint at ``http://localhost:8231/health``. It returns ``ok``.

Stop the server when you're done.

To start a quick server from your shell instead, run:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"

Stop it the same way.

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

.. code-block:: js

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

Stop that process too.
```

#### 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="http-local-server">
  <title>Run a local server</title>
  <body>
    <p>Start the sample API server. It takes the port as an argument and prints <codeph>Listening</codeph> when it's ready:</p>
    <codeblock outputclass="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</codeblock>
    <p>Check the server's health endpoint at <codeph>http://localhost:8231/health</codeph>. It returns <codeph>ok</codeph>.</p>
    <p>Stop the server when you're done.</p>
    <p>To start a quick server from your shell instead, run:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</codeblock>
    <p>Stop it the same way.</p>
    <p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
    <p>Stop that process too.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-local-server","detectSteps":true} -->

# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js testIgnore
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

<!-- step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} -->

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

<!-- step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} -->

Stop the server when you're done.

<!-- step {"closeSurface":"http-local-api"} -->

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} -->

Stop it the same way.

<!-- step {"closeSurface":"http-local-shell"} -->

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

<!-- step {"closeSurface":"http-local-tty"} -->

```js testIgnore
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

<!-- step {"closeSurface":"http-local-tty-code"} -->

<!-- step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} -->

Stop that process too.

<!-- step {"closeSurface":"http-local-tty-small"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-local-server","detectSteps":true} */}

# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js testIgnore
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

{/* step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} */}

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

{/* step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} */}

Stop the server when you're done.

{/* step {"closeSurface":"http-local-api"} */}

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} */}

Stop it the same way.

{/* step {"closeSurface":"http-local-shell"} */}

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} */}

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

{/* step {"closeSurface":"http-local-tty"} */}

```js testIgnore
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

{/* step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

{/* step {"closeSurface":"http-local-tty-code"} */}

{/* step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} */}

Stop that process too.

{/* step {"closeSurface":"http-local-tty-small"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a local server

// (test {"testId":"http-local-server","detectSteps":true})

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

[source,js,testIgnore]
----
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
----

// (step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}})

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

// (step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}})

Stop the server when you're done.

// (step {"closeSurface":"http-local-api"})

To start a quick server from your shell instead, run:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}})

Stop it the same way.

// (step {"closeSurface":"http-local-shell"})

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}})

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

// (step {"closeSurface":"http-local-tty"})

[source,js,testIgnore]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

// (step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

// (step {"closeSurface":"http-local-tty-code"})

// (step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}})

Stop that process too.

// (step {"closeSurface":"http-local-tty-small"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a local server</title></head>
<body>
<!-- test {"testId":"http-local-server","detectSteps":true} -->
<h1>Run a local server</h1>
<p>Start the sample API server. It takes the port as an argument and prints <code>Listening</code> when it's ready:</p>
<!-- test ignore start -->
<pre><code class="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} -->
<p>Check the server's health endpoint at <code>http://localhost:8231/health</code>. It returns <code>ok</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} -->
<p>Stop the server when you're done.</p>
<!-- step {"closeSurface":"http-local-api"} -->
<p>To start a quick server from your shell instead, run:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} -->
<p>Stop it the same way.</p>
<!-- step {"closeSurface":"http-local-shell"} -->
<p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->
<p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
<!-- step {"closeSurface":"http-local-tty"} -->
<!-- test ignore start -->
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
<!-- step {"closeSurface":"http-local-tty-code"} -->
<!-- step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} -->
<p>Stop that process too.</p>
<!-- step {"closeSurface":"http-local-tty-small"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a local server
==================

.. test {"testId":"http-local-server","detectSteps":true}

Start the sample API server. It takes the port as an argument and prints ``Listening`` when it's ready:

.. code-block:: js
   :class: testIgnore

   const http = require("http");
   const port = Number(process.argv[2]);
   http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));

.. step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}}

Check the server's health endpoint at ``http://localhost:8231/health``. It returns ``ok``.

.. step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}}

Stop the server when you're done.

.. step {"closeSurface":"http-local-api"}

To start a quick server from your shell instead, run:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}}

Stop it the same way.

.. step {"closeSurface":"http-local-shell"}

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

.. step {"closeSurface":"http-local-tty"}

.. code-block:: js
   :class: testIgnore

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

.. step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

.. step {"closeSurface":"http-local-tty-code"}

.. step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}}

Stop that process too.

.. step {"closeSurface":"http-local-tty-small"}

.. 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="http-local-server">
  <title>Run a local server</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-local-server","detectSteps":true}'/>
    <p>Start the sample API server. It takes the port as an argument and prints <codeph>Listening</codeph> when it's ready:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}}'/>
    <p>Check the server's health endpoint at <codeph>http://localhost:8231/health</codeph>. It returns <codeph>ok</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}}'/>
    <p>Stop the server when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-api"}'/>
    <p>To start a quick server from your shell instead, run:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}}'/>
    <p>Stop it the same way.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-shell"}'/>
    <p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}'/>
    <p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty"}'/>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty-code"}'/>
    <data name="doc-detective" value='step {"runCode":{"language":"bash","code":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}}'/>
    <p>Stop that process too.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty-small"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-local-server","detectSteps":false} -->

# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

<!-- step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} -->

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

<!-- step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} -->

Stop the server when you're done.

<!-- step {"closeSurface":"http-local-api"} -->

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} -->

Stop it the same way.

<!-- step {"closeSurface":"http-local-shell"} -->

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

<!-- step {"closeSurface":"http-local-tty"} -->

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

<!-- step {"closeSurface":"http-local-tty-code"} -->

<!-- step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} -->

Stop that process too.

<!-- step {"closeSurface":"http-local-tty-small"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-local-server","detectSteps":false} */}

# Run a local server

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

```js
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
```

{/* step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} */}

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

{/* step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} */}

Stop the server when you're done.

{/* step {"closeSurface":"http-local-api"} */}

To start a quick server from your shell instead, run:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} */}

Stop it the same way.

{/* step {"closeSurface":"http-local-shell"} */}

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} */}

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

{/* step {"closeSurface":"http-local-tty"} */}

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

{/* step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

{/* step {"closeSurface":"http-local-tty-code"} */}

{/* step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} */}

Stop that process too.

{/* step {"closeSurface":"http-local-tty-small"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a local server

// (test {"testId":"http-local-server","detectSteps":false})

Start the sample API server. It takes the port as an argument and prints `Listening` when it's ready:

[source,js]
----
const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
----

// (step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}})

Check the server's health endpoint at `http://localhost:8231/health`. It returns `ok`.

// (step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}})

Stop the server when you're done.

// (step {"closeSurface":"http-local-api"})

To start a quick server from your shell instead, run:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}})

Stop it the same way.

// (step {"closeSurface":"http-local-shell"})

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}})

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

// (step {"closeSurface":"http-local-tty"})

[source,js]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

// (step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

// (step {"closeSurface":"http-local-tty-code"})

// (step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}})

Stop that process too.

// (step {"closeSurface":"http-local-tty-small"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a local server</title></head>
<body>
<!-- test {"testId":"http-local-server","detectSteps":false} -->
<h1>Run a local server</h1>
<p>Start the sample API server. It takes the port as an argument and prints <code>Listening</code> when it's ready:</p>
<pre><code class="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</code></pre>
<!-- step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}} -->
<p>Check the server's health endpoint at <code>http://localhost:8231/health</code>. It returns <code>ok</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}} -->
<p>Stop the server when you're done.</p>
<!-- step {"closeSurface":"http-local-api"} -->
<p>To start a quick server from your shell instead, run:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}} -->
<p>Stop it the same way.</p>
<!-- step {"closeSurface":"http-local-shell"} -->
<p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->
<p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
<!-- step {"closeSurface":"http-local-tty"} -->
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
<!-- step {"closeSurface":"http-local-tty-code"} -->
<!-- step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}} -->
<p>Stop that process too.</p>
<!-- step {"closeSurface":"http-local-tty-small"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a local server
==================

.. test {"testId":"http-local-server","detectSteps":false}

Start the sample API server. It takes the port as an argument and prints ``Listening`` when it's ready:

.. code-block:: js

   const http = require("http");
   const port = Number(process.argv[2]);
   http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));

.. step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}}

Check the server's health endpoint at ``http://localhost:8231/health``. It returns ``ok``.

.. step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}}

Stop the server when you're done.

.. step {"closeSurface":"http-local-api"}

To start a quick server from your shell instead, run:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}}

Stop it the same way.

.. step {"closeSurface":"http-local-shell"}

Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}

Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:

.. step {"closeSurface":"http-local-tty"}

.. code-block:: js

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

.. step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.

.. step {"closeSurface":"http-local-tty-code"}

.. step {"runCode":{"language":"bash","code":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}}

Stop that process too.

.. step {"closeSurface":"http-local-tty-small"}

.. 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="http-local-server">
  <title>Run a local server</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-local-server","detectSteps":false}'/>
    <p>Start the sample API server. It takes the port as an argument and prints <codeph>Listening</codeph> when it's ready:</p>
    <codeblock outputclass="language-js">const http = require("http");
const port = Number(process.argv[2]);
http.createServer((req, res) =&gt; res.end("ok")).listen(port, () =&gt; console.log("Listening"));</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));","args":["8231"],"background":{"name":"http-local-api","waitUntil":{"port":8231,"stdio":"Listening","httpGet":"http://localhost:8231/health","delayMs":100}},"timeout":15000}}'/>
    <p>Check the server's health endpoint at <codeph>http://localhost:8231/health</codeph>. It returns <codeph>ok</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8231/health","statusCodes":200,"response":{"body":"ok"}}}'/>
    <p>Stop the server when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-api"}'/>
    <p>To start a quick server from your shell instead, run:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8232)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8232)\"","background":{"name":"http-local-shell","tty":true,"waitUntil":{"port":8232,"httpGet":"http://localhost:8232/"}},"timeout":15000}}'/>
    <p>Stop it the same way.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-shell"}'/>
    <p>Terminal apps size their output to the terminal. To see the size an app gets in a 100-by-40 terminal, run:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}'/>
    <p>Stop it, then run the same check as JavaScript, in the default 120-by-30 terminal:</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty"}'/>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-local-tty-code","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop that process, then run the same check from a Bash script in an 80-by-24 terminal.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty-code"}'/>
    <data name="doc-detective" value='step {"runCode":{"language":"bash","code":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-local-tty-small","tty":{"cols":80,"rows":24},"waitUntil":{"stdio":"Terminal: 80x24"}},"timeout":30000}}'/>
    <p>Stop that process too.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-local-tty-small"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-local-server",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "const http = require(\"http\");\nconst port = Number(process.argv[2]);\nhttp.createServer((req, res) => res.end(\"ok\")).listen(port, () => console.log(\"Listening\"));",
            "args": [
              "8231"
            ],
            "background": {
              "name": "http-local-api",
              "waitUntil": {
                "port": 8231,
                "stdio": "Listening",
                "httpGet": "http://localhost:8231/health",
                "delayMs": 100
              }
            },
            "timeout": 15000
          }
        },
        {
          "httpRequest": {
            "url": "http://localhost:8231/health",
            "statusCodes": 200,
            "response": {
              "body": "ok"
            }
          }
        },
        {
          "closeSurface": "http-local-api"
        },
        {
          "runShell": {
            "command": "node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8232)\"",
            "background": {
              "name": "http-local-shell",
              "tty": true,
              "waitUntil": {
                "port": 8232,
                "httpGet": "http://localhost:8232/"
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-local-shell"
        },
        {
          "runShell": {
            "command": "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"",
            "background": {
              "name": "http-local-tty",
              "tty": {
                "cols": 100,
                "rows": 40
              },
              "waitUntil": {
                "stdio": "Terminal: 100x40"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-local-tty"
        },
        {
          "runCode": {
            "language": "js",
            "code": "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);",
            "background": {
              "name": "http-local-tty-code",
              "tty": true,
              "waitUntil": {
                "stdio": "Terminal: 120x30"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-local-tty-code"
        },
        {
          "runCode": {
            "language": "bash",
            "code": "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"",
            "background": {
              "name": "http-local-tty-small",
              "tty": {
                "cols": 80,
                "rows": 24
              },
              "waitUntil": {
                "stdio": "Terminal: 80x24"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-local-tty-small"
        }
      ]
    }
  ]
}
```

#### 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: http-local-server
    steps:
      - runCode:
          language: js
          code: |-
            const http = require("http");
            const port = Number(process.argv[2]);
            http.createServer((req, res) => res.end("ok")).listen(port, () => console.log("Listening"));
          args:
            - "8231"
          background:
            name: http-local-api
            waitUntil:
              port: 8231
              stdio: Listening
              httpGet: http://localhost:8231/health
              delayMs: 100
          timeout: 15000
      - httpRequest:
          url: http://localhost:8231/health
          statusCodes: 200
          response:
            body: ok
      - closeSurface: http-local-api
      - runShell:
          command: node -e "require('http').createServer((q, r) => r.end('ok')).listen(8232)"
          background:
            name: http-local-shell
            tty: true
            waitUntil:
              port: 8232
              httpGet: http://localhost:8232/
          timeout: 15000
      - closeSurface: http-local-shell
      - runShell:
          command: "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\""
          background:
            name: http-local-tty
            tty:
              cols: 100
              rows: 40
            waitUntil:
              stdio: "Terminal: 100x40"
          timeout: 30000
      - closeSurface: http-local-tty
      - runCode:
          language: js
          code: "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
          background:
            name: http-local-tty-code
            tty: true
            waitUntil:
              stdio: "Terminal: 120x30"
          timeout: 30000
      - closeSurface: http-local-tty-code
      - runCode:
          language: bash
          code: "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\""
          background:
            name: http-local-tty-small
            tty:
              cols: 80
              rows: 24
            waitUntil:
              stdio: "Terminal: 80x24"
          timeout: 30000
      - closeSurface: http-local-tty-small
```

### Notes

* The `js` and `bash` code blocks run until you stop them, so a detected `runCode` step would wait for them to exit and time out. Each block is marked `testIgnore`, or wrapped in `test ignore` statements in HTML and DITA, and each variant carries its steps in statements.
* The server step passes the port as `args`. The server is ready once its port accepts connections, its output contains `Listening`, and its health check returns a `2xx` status. The step also waits at least 100 milliseconds.
* `tty` runs a process in a terminal instead of a pipe, so apps that check for a terminal render.
* With `tty` set to `true`, the terminal is 120 columns by 30 rows. An object with `cols` and `rows` sets the size.
* The JavaScript `tty` step runs Node.js in the terminal, and the Bash one runs the same check through a shell script.
* The shell server also sets `tty` to `true`, and still answers on its port.

## `httpRequest` permutations

### `method: "get"`

**Varies:** `httpRequest.method` · **Value:** `get` · **Effect:** sends a `GET` request, and the echo API returns the query parameters.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>GET a user</title></head>
<body>
<h1>GET a user</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
GET a user
==========

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``.
```

#### 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="http-request-method-get">
  <title>GET a user</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-method-get","detectSteps":true} -->

# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-method-get","detectSteps":true} */}

# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= GET a user

// (test {"testId":"http-request-method-get","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>GET a user</title></head>
<body>
<!-- test {"testId":"http-request-method-get","detectSteps":true} -->
<h1>GET a user</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
GET a user
==========

.. test {"testId":"http-request-method-get","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}}

.. 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="http-request-method-get">
  <title>GET a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-get","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-method-get","detectSteps":false} -->

# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-method-get","detectSteps":false} */}

# GET a user

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= GET a user

// (test {"testId":"http-request-method-get","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users?page=2`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>GET a user</title></head>
<body>
<!-- test {"testId":"http-request-method-get","detectSteps":false} -->
<h1>GET a user</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
GET a user
==========

.. test {"testId":"http-request-method-get","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}}

.. 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="http-request-method-get">
  <title>GET a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-get","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","response":{"body":{"page":"2"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-method-get",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "method": "get",
            "response": {
              "body": {
                "page": "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: http-request-method-get
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          method: get
          response:
            body:
              page: "2"
```

### `method: "post"`

**Varies:** `httpRequest.method` · **Value:** `post` · **Effect:** sends a `POST` request with an object body, and the echo API returns the body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>POST a user</title></head>
<body>
<h1>POST a user</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name":"Ada"}</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
POST a user
===========

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name":"Ada"}``.
```

#### 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="http-request-method-post">
  <title>POST a user</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name":"Ada"}</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-method-post","detectSteps":true} -->

# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-method-post","detectSteps":true} */}

# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= POST a user

// (test {"testId":"http-request-method-post","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>POST a user</title></head>
<body>
<!-- test {"testId":"http-request-method-post","detectSteps":true} -->
<h1>POST a user</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name":"Ada"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
POST a user
===========

.. test {"testId":"http-request-method-post","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name":"Ada"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-request-method-post">
  <title>POST a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-post","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name":"Ada"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-method-post","detectSteps":false} -->

# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-method-post","detectSteps":false} */}

# POST a user

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= POST a user

// (test {"testId":"http-request-method-post","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name":"Ada"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>POST a user</title></head>
<body>
<!-- test {"testId":"http-request-method-post","detectSteps":false} -->
<h1>POST a user</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name":"Ada"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
POST a user
===========

.. test {"testId":"http-request-method-post","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name":"Ada"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-request-method-post">
  <title>POST a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-post","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name":"Ada"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-method-post",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "method": "post",
            "request": {
              "body": {
                "name": "Ada"
              }
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-method-post
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          method: post
          request:
            body: &a1
              name: Ada
          response:
            body: *a1
```

### `method: "put"`

**Varies:** `httpRequest.method` · **Value:** `put` · **Effect:** sends a `PUT` request, and the echo API returns the body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PUT a user</title></head>
<body>
<h1>PUT a user</h1>
<p>Send a <code>PUT</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
PUT a user
==========

Send a ``PUT`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.
```

#### 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="http-request-method-put">
  <title>PUT a user</title>
  <body>
    <p>Send a <codeph>PUT</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-method-put","detectSteps":true} -->

# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-method-put","detectSteps":true} */}

# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= PUT a user

// (test {"testId":"http-request-method-put","detectSteps":true})

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PUT a user</title></head>
<body>
<!-- test {"testId":"http-request-method-put","detectSteps":true} -->
<h1>PUT a user</h1>
<p>Send a <code>PUT</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
PUT a user
==========

.. test {"testId":"http-request-method-put","detectSteps":true}

Send a ``PUT`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}

.. 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="http-request-method-put">
  <title>PUT a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-put","detectSteps":true}'/>
    <p>Send a <codeph>PUT</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-method-put","detectSteps":false} -->

# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-method-put","detectSteps":false} */}

# PUT a user

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= PUT a user

// (test {"testId":"http-request-method-put","detectSteps":false})

Send a `PUT` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PUT a user</title></head>
<body>
<!-- test {"testId":"http-request-method-put","detectSteps":false} -->
<h1>PUT a user</h1>
<p>Send a <code>PUT</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
PUT a user
==========

.. test {"testId":"http-request-method-put","detectSteps":false}

Send a ``PUT`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}

.. 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="http-request-method-put">
  <title>PUT a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-put","detectSteps":false}'/>
    <p>Send a <codeph>PUT</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"put","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-method-put",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users/2",
            "method": "put",
            "request": {
              "body": {
                "job": "lead"
              }
            },
            "response": {
              "body": {
                "job": "lead"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-method-put
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users/2
          method: put
          request:
            body: &a1
              job: lead
          response:
            body: *a1
```

### `method: "patch"`

**Varies:** `httpRequest.method` · **Value:** `patch` · **Effect:** sends a `PATCH` request, and the echo API returns the body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PATCH a user</title></head>
<body>
<h1>PATCH a user</h1>
<p>Send a <code>PATCH</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
PATCH a user
============

Send a ``PATCH`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.
```

#### 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="http-request-method-patch">
  <title>PATCH a user</title>
  <body>
    <p>Send a <codeph>PATCH</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-method-patch","detectSteps":true} -->

# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-method-patch","detectSteps":true} */}

# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= PATCH a user

// (test {"testId":"http-request-method-patch","detectSteps":true})

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PATCH a user</title></head>
<body>
<!-- test {"testId":"http-request-method-patch","detectSteps":true} -->
<h1>PATCH a user</h1>
<p>Send a <code>PATCH</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
PATCH a user
============

.. test {"testId":"http-request-method-patch","detectSteps":true}

Send a ``PATCH`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}

.. 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="http-request-method-patch">
  <title>PATCH a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-patch","detectSteps":true}'/>
    <p>Send a <codeph>PATCH</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-method-patch","detectSteps":false} -->

# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-method-patch","detectSteps":false} */}

# PATCH a user

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= PATCH a user

// (test {"testId":"http-request-method-patch","detectSteps":false})

Send a `PATCH` request to `http://localhost:8093/api/users/2` with the body `{"job":"lead"}`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>PATCH a user</title></head>
<body>
<!-- test {"testId":"http-request-method-patch","detectSteps":false} -->
<h1>PATCH a user</h1>
<p>Send a <code>PATCH</code> request to <code>http://localhost:8093/api/users/2</code> with the body <code>{"job":"lead"}</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
PATCH a user
============

.. test {"testId":"http-request-method-patch","detectSteps":false}

Send a ``PATCH`` request to ``http://localhost:8093/api/users/2`` with the body ``{"job":"lead"}``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}

.. 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="http-request-method-patch">
  <title>PATCH a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-patch","detectSteps":false}'/>
    <p>Send a <codeph>PATCH</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph> with the body <codeph>{"job":"lead"}</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"patch","request":{"body":{"job":"lead"}},"response":{"body":{"job":"lead"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-method-patch",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users/2",
            "method": "patch",
            "request": {
              "body": {
                "job": "lead"
              }
            },
            "response": {
              "body": {
                "job": "lead"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-method-patch
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users/2
          method: patch
          request:
            body: &a1
              job: lead
          response:
            body: *a1
```

### `method: "delete"`

**Varies:** `httpRequest.method` · **Value:** `delete` · **Effect:** sends a `DELETE` request, and the step passes on a `200` status.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>DELETE a user</title></head>
<body>
<h1>DELETE a user</h1>
<p>Send a <code>DELETE</code> request to <code>http://localhost:8093/api/users/2</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
DELETE a user
=============

Send a ``DELETE`` request to ``http://localhost:8093/api/users/2``.
```

#### 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="http-request-method-delete">
  <title>DELETE a user</title>
  <body>
    <p>Send a <codeph>DELETE</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-method-delete","detectSteps":true} -->

# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-method-delete","detectSteps":true} */}

# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= DELETE a user

// (test {"testId":"http-request-method-delete","detectSteps":true})

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>DELETE a user</title></head>
<body>
<!-- test {"testId":"http-request-method-delete","detectSteps":true} -->
<h1>DELETE a user</h1>
<p>Send a <code>DELETE</code> request to <code>http://localhost:8093/api/users/2</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
DELETE a user
=============

.. test {"testId":"http-request-method-delete","detectSteps":true}

Send a ``DELETE`` request to ``http://localhost:8093/api/users/2``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}}

.. 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="http-request-method-delete">
  <title>DELETE a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-delete","detectSteps":true}'/>
    <p>Send a <codeph>DELETE</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-method-delete","detectSteps":false} -->

# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-method-delete","detectSteps":false} */}

# DELETE a user

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= DELETE a user

// (test {"testId":"http-request-method-delete","detectSteps":false})

Send a `DELETE` request to `http://localhost:8093/api/users/2`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>DELETE a user</title></head>
<body>
<!-- test {"testId":"http-request-method-delete","detectSteps":false} -->
<h1>DELETE a user</h1>
<p>Send a <code>DELETE</code> request to <code>http://localhost:8093/api/users/2</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
DELETE a user
=============

.. test {"testId":"http-request-method-delete","detectSteps":false}

Send a ``DELETE`` request to ``http://localhost:8093/api/users/2``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}}

.. 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="http-request-method-delete">
  <title>DELETE a user</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-method-delete","detectSteps":false}'/>
    <p>Send a <codeph>DELETE</codeph> request to <codeph>http://localhost:8093/api/users/2</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/2","method":"delete"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-method-delete",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users/2",
            "method": "delete"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-method-delete
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users/2
          method: delete
```

### `request.headers` as a string

**Varies:** `httpRequest.request.headers` · **Value:** `"X-Test: docs"` · **Effect:** sends one `Name: value` header per line, and the echo API repeats `X-Test` in its `x-echo-test` header.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as a string</title></head>
<body>
<h1>Send a header as a string</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a header as a string
=========================

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.
```

#### 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="http-request-headers-string">
  <title>Send a header as a string</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-headers-string","detectSteps":true} -->

# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-headers-string","detectSteps":true} */}

# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a header as a string

// (test {"testId":"http-request-headers-string","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as a string</title></head>
<body>
<!-- test {"testId":"http-request-headers-string","detectSteps":true} -->
<h1>Send a header as a string</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a header as a string
=========================

.. test {"testId":"http-request-headers-string","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}}

.. 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="http-request-headers-string">
  <title>Send a header as a string</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-headers-string","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-headers-string","detectSteps":false} -->

# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-headers-string","detectSteps":false} */}

# Send a header as a string

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a header as a string

// (test {"testId":"http-request-headers-string","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as a string</title></head>
<body>
<!-- test {"testId":"http-request-headers-string","detectSteps":false} -->
<h1>Send a header as a string</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a header as a string
=========================

.. test {"testId":"http-request-headers-string","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}}

.. 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="http-request-headers-string">
  <title>Send a header as a string</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-headers-string","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":"X-Test: docs"},"response":{"headers":{"x-echo-test":"docs"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-headers-string",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "request": {
              "headers": "X-Test: docs"
            },
            "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: http-request-headers-string
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          request:
            headers: "X-Test: docs"
          response:
            headers:
              x-echo-test: docs
```

### `request.headers` as an object

**Varies:** `httpRequest.request.headers` · **Value:** `{"X-Test": "docs"}` · **Effect:** sends each key as a header name, with the same result as the string form.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as an object</title></head>
<body>
<h1>Send a header as an object</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a header as an object
==========================

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.
```

#### 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="http-request-headers-object">
  <title>Send a header as an object</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-headers-object","detectSteps":true} -->

# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-headers-object","detectSteps":true} */}

# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a header as an object

// (test {"testId":"http-request-headers-object","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as an object</title></head>
<body>
<!-- test {"testId":"http-request-headers-object","detectSteps":true} -->
<h1>Send a header as an object</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a header as an object
==========================

.. test {"testId":"http-request-headers-object","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}}

.. 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="http-request-headers-object">
  <title>Send a header as an object</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-headers-object","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-headers-object","detectSteps":false} -->

# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-headers-object","detectSteps":false} */}

# Send a header as an object

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a header as an object

// (test {"testId":"http-request-headers-object","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users` with the header `X-Test: docs`. The response's `x-echo-test` header is `docs`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a header as an object</title></head>
<body>
<!-- test {"testId":"http-request-headers-object","detectSteps":false} -->
<h1>Send a header as an object</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the header <code>X-Test: docs</code>. The response's <code>x-echo-test</code> header is <code>docs</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a header as an object
==========================

.. test {"testId":"http-request-headers-object","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the header ``X-Test: docs``. The response's ``x-echo-test`` header is ``docs``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}}

.. 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="http-request-headers-object">
  <title>Send a header as an object</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-headers-object","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the header <codeph>X-Test: docs</codeph>. The response's <codeph>x-echo-test</codeph> header is <codeph>docs</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"headers":{"X-Test":"docs"}},"response":{"headers":{"x-echo-test":"docs"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-headers-object",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "request": {
              "headers": {
                "X-Test": "docs"
              }
            },
            "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: http-request-headers-object
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          request:
            headers:
              X-Test: docs
          response:
            headers:
              x-echo-test: docs
```

### `request.parameters`

**Varies:** `httpRequest.request.parameters` · **Value:** `{"page": "2"}` · **Effect:** adds `?page=2` to the URL.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send query parameters</title></head>
<body>
<h1>Send query parameters</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the <code>page</code> parameter set to <code>2</code>. The response echoes it.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send query parameters
=====================

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the ``page`` parameter set to ``2``. The response echoes it.
```

#### 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="http-request-parameters">
  <title>Send query parameters</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the <codeph>page</codeph> parameter set to <codeph>2</codeph>. The response echoes it.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-parameters","detectSteps":true} -->

# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-parameters","detectSteps":true} */}

# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send query parameters

// (test {"testId":"http-request-parameters","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send query parameters</title></head>
<body>
<!-- test {"testId":"http-request-parameters","detectSteps":true} -->
<h1>Send query parameters</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the <code>page</code> parameter set to <code>2</code>. The response echoes it.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send query parameters
=====================

.. test {"testId":"http-request-parameters","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the ``page`` parameter set to ``2``. The response echoes it.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}}

.. 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="http-request-parameters">
  <title>Send query parameters</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-parameters","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the <codeph>page</codeph> parameter set to <codeph>2</codeph>. The response echoes it.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-parameters","detectSteps":false} -->

# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-parameters","detectSteps":false} */}

# Send query parameters

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send query parameters

// (test {"testId":"http-request-parameters","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users` with the `page` parameter set to `2`. The response echoes it.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send query parameters</title></head>
<body>
<!-- test {"testId":"http-request-parameters","detectSteps":false} -->
<h1>Send query parameters</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users</code> with the <code>page</code> parameter set to <code>2</code>. The response echoes it.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send query parameters
=====================

.. test {"testId":"http-request-parameters","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users`` with the ``page`` parameter set to ``2``. The response echoes it.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}}

.. 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="http-request-parameters">
  <title>Send query parameters</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-parameters","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the <codeph>page</codeph> parameter set to <codeph>2</codeph>. The response echoes it.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","request":{"parameters":{"page":"2"}},"response":{"body":{"page":"2"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-parameters",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "request": {
              "parameters": {
                "page": "2"
              }
            },
            "response": {
              "body": {
                "page": "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: http-request-parameters
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          request:
            parameters:
              page: "2"
          response:
            body:
              page: "2"
```

### `request.body` as a string

**Varies:** `httpRequest.request.body` · **Value:** `"{\"name\": \"Ada\"}"` · **Effect:** sends the string as is, so the `Content-Type` header tells the server it's JSON.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a JSON string body</title></head>
<body>
<h1>Send a JSON string body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the JSON body <code>{"name": "Ada"}</code>. The response echoes it.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a JSON string body
=======================

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the JSON body ``{"name": "Ada"}``. The response echoes it.
```

#### 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="http-request-body-string">
  <title>Send a JSON string body</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the JSON body <codeph>{"name": "Ada"}</codeph>. The response echoes it.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-body-string","detectSteps":true} -->

# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-body-string","detectSteps":true} */}

# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a JSON string body

// (test {"testId":"http-request-body-string","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a JSON string body</title></head>
<body>
<!-- test {"testId":"http-request-body-string","detectSteps":true} -->
<h1>Send a JSON string body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the JSON body <code>{"name": "Ada"}</code>. The response echoes it.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a JSON string body
=======================

.. test {"testId":"http-request-body-string","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the JSON body ``{"name": "Ada"}``. The response echoes it.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-request-body-string">
  <title>Send a JSON string body</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-body-string","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the JSON body <codeph>{"name": "Ada"}</codeph>. The response echoes it.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-body-string","detectSteps":false} -->

# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-body-string","detectSteps":false} */}

# Send a JSON string body

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a JSON string body

// (test {"testId":"http-request-body-string","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/users` with the JSON body `{"name": "Ada"}`. The response echoes it.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a JSON string body</title></head>
<body>
<!-- test {"testId":"http-request-body-string","detectSteps":false} -->
<h1>Send a JSON string body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the JSON body <code>{"name": "Ada"}</code>. The response echoes it.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a JSON string body
=======================

.. test {"testId":"http-request-body-string","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the JSON body ``{"name": "Ada"}``. The response echoes it.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-request-body-string">
  <title>Send a JSON string body</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-body-string","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the JSON body <codeph>{"name": "Ada"}</codeph>. The response echoes it.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Ada\"}"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-body-string",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "method": "post",
            "request": {
              "headers": {
                "Content-Type": "application/json"
              },
              "body": "{\"name\": \"Ada\"}"
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-body-string
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          method: post
          request:
            headers:
              Content-Type: application/json
            body: '{"name": "Ada"}'
          response:
            body:
              name: Ada
```

### `request.body` and `response.body` as arrays

**Varies:** `httpRequest.request.body` · **Value:** `[{"name": "Ada"}, {"name": "Grace"}]` · **Effect:** sends a JSON array, and `response.body` expects the same array back.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send an array body</title></head>
<body>
<h1>Send an array body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users/batch</code> with two users in an array. The response echoes the array.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send an array body
==================

Send a ``POST`` request to ``http://localhost:8093/api/users/batch`` with two users in an array. The response echoes the array.
```

#### 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="http-request-body-array">
  <title>Send an array body</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users/batch</codeph> with two users in an array. The response echoes the array.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-body-array","detectSteps":true} -->

# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-body-array","detectSteps":true} */}

# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send an array body

// (test {"testId":"http-request-body-array","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send an array body</title></head>
<body>
<!-- test {"testId":"http-request-body-array","detectSteps":true} -->
<h1>Send an array body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users/batch</code> with two users in an array. The response echoes the array.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send an array body
==================

.. test {"testId":"http-request-body-array","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/users/batch`` with two users in an array. The response echoes the array.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}

.. 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="http-request-body-array">
  <title>Send an array body</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-body-array","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users/batch</codeph> with two users in an array. The response echoes the array.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-body-array","detectSteps":false} -->

# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-body-array","detectSteps":false} */}

# Send an array body

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send an array body

// (test {"testId":"http-request-body-array","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/users/batch` with two users in an array. The response echoes the array.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send an array body</title></head>
<body>
<!-- test {"testId":"http-request-body-array","detectSteps":false} -->
<h1>Send an array body</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users/batch</code> with two users in an array. The response echoes the array.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send an array body
==================

.. test {"testId":"http-request-body-array","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/users/batch`` with two users in an array. The response echoes the array.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}

.. 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="http-request-body-array">
  <title>Send an array body</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-body-array","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users/batch</codeph> with two users in an array. The response echoes the array.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users/batch","method":"post","request":{"headers":{"Content-Type":"application/json"},"body":[{"name":"Ada"},{"name":"Grace"}]},"response":{"body":[{"name":"Ada"},{"name":"Grace"}]}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-body-array",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users/batch",
            "method": "post",
            "request": {
              "headers": {
                "Content-Type": "application/json"
              },
              "body": [
                {
                  "name": "Ada"
                },
                {
                  "name": "Grace"
                }
              ]
            },
            "response": {
              "body": [
                {
                  "name": "Ada"
                },
                {
                  "name": "Grace"
                }
              ]
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-body-array
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users/batch
          method: post
          request:
            headers:
              Content-Type: application/json
            body:
              - name: Ada
              - name: Grace
          response:
            body:
              - name: Ada
              - name: Grace
```

### `statusCodes` as a number

**Varies:** `httpRequest.statusCodes` · **Value:** `404` · **Effect:** accepts only `404`, so a missing page passes and a `200` would fail.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a 404 status</title></head>
<body>
<h1>Expect a 404 status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/404</code>. The status is <code>404</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Expect a 404 status
===================

Send a ``GET`` request to ``http://localhost:8092/status/404``. The status is ``404``.
```

#### 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="http-request-statuscodes-number">
  <title>Expect a 404 status</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/404</codeph>. The status is <codeph>404</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-statuscodes-number","detectSteps":true} -->

# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

<!-- step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-statuscodes-number","detectSteps":true} */}

# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

{/* step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Expect a 404 status

// (test {"testId":"http-request-statuscodes-number","detectSteps":true})

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

// (step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a 404 status</title></head>
<body>
<!-- test {"testId":"http-request-statuscodes-number","detectSteps":true} -->
<h1>Expect a 404 status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/404</code>. The status is <code>404</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Expect a 404 status
===================

.. test {"testId":"http-request-statuscodes-number","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8092/status/404``. The status is ``404``.

.. step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}}

.. 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="http-request-statuscodes-number">
  <title>Expect a 404 status</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-statuscodes-number","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/404</codeph>. The status is <codeph>404</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-statuscodes-number","detectSteps":false} -->

# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

<!-- step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-statuscodes-number","detectSteps":false} */}

# Expect a 404 status

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

{/* step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Expect a 404 status

// (test {"testId":"http-request-statuscodes-number","detectSteps":false})

Send a `GET` request to `http://localhost:8092/status/404`. The status is `404`.

// (step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a 404 status</title></head>
<body>
<!-- test {"testId":"http-request-statuscodes-number","detectSteps":false} -->
<h1>Expect a 404 status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/404</code>. The status is <code>404</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Expect a 404 status
===================

.. test {"testId":"http-request-statuscodes-number","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8092/status/404``. The status is ``404``.

.. step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}}

.. 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="http-request-statuscodes-number">
  <title>Expect a 404 status</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-statuscodes-number","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/404</codeph>. The status is <codeph>404</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/status/404","statusCodes":404}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-statuscodes-number",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/status/404",
            "statusCodes": 404
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-statuscodes-number
    steps:
      - httpRequest:
          url: http://localhost:8092/status/404
          statusCodes: 404
```

### `statusCodes` as an array

**Varies:** `httpRequest.statusCodes` · **Value:** `[200, 201]` · **Effect:** accepts any status in the list.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Accept either success status</title></head>
<body>
<h1>Accept either success status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/201</code>. The status is <code>200</code> or <code>201</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Accept either success status
============================

Send a ``GET`` request to ``http://localhost:8092/status/201``. The status is ``200`` or ``201``.
```

#### 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="http-request-statuscodes-array">
  <title>Accept either success status</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/201</codeph>. The status is <codeph>200</codeph> or <codeph>201</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-statuscodes-array","detectSteps":true} -->

# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

<!-- step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-statuscodes-array","detectSteps":true} */}

# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

{/* step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Accept either success status

// (test {"testId":"http-request-statuscodes-array","detectSteps":true})

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

// (step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Accept either success status</title></head>
<body>
<!-- test {"testId":"http-request-statuscodes-array","detectSteps":true} -->
<h1>Accept either success status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/201</code>. The status is <code>200</code> or <code>201</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Accept either success status
============================

.. test {"testId":"http-request-statuscodes-array","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8092/status/201``. The status is ``200`` or ``201``.

.. step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}}

.. 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="http-request-statuscodes-array">
  <title>Accept either success status</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-statuscodes-array","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/201</codeph>. The status is <codeph>200</codeph> or <codeph>201</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-statuscodes-array","detectSteps":false} -->

# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

<!-- step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-statuscodes-array","detectSteps":false} */}

# Accept either success status

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

{/* step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Accept either success status

// (test {"testId":"http-request-statuscodes-array","detectSteps":false})

Send a `GET` request to `http://localhost:8092/status/201`. The status is `200` or `201`.

// (step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Accept either success status</title></head>
<body>
<!-- test {"testId":"http-request-statuscodes-array","detectSteps":false} -->
<h1>Accept either success status</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/status/201</code>. The status is <code>200</code> or <code>201</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Accept either success status
============================

.. test {"testId":"http-request-statuscodes-array","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8092/status/201``. The status is ``200`` or ``201``.

.. step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}}

.. 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="http-request-statuscodes-array">
  <title>Accept either success status</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-statuscodes-array","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/status/201</codeph>. The status is <codeph>200</codeph> or <codeph>201</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/status/201","statusCodes":[200,201]}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-statuscodes-array",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/status/201",
            "statusCodes": [
              200,
              201
            ]
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-statuscodes-array
    steps:
      - httpRequest:
          url: http://localhost:8092/status/201
          statusCodes:
            - 200
            - 201
```

### `allowAdditionalFields: true`

**Varies:** `httpRequest.allowAdditionalFields` · **Value:** `true` · **Effect:** passes when the response holds fields that `response.body` doesn't list, such as the `8092` server's `extraField`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Allow extra response fields</title></head>
<body>
<h1>Allow extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8092/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds <code>name</code> and an extra field.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Allow extra response fields
===========================

Send a ``POST`` request to ``http://localhost:8092/api/users`` with the body ``{"name": "Ada"}``. The response holds ``name`` and an extra field.
```

#### 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="http-request-additional-fields-true">
  <title>Allow extra response fields</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds <codeph>name</codeph> and an extra field.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-additional-fields-true","detectSteps":true} -->

# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-additional-fields-true","detectSteps":true} */}

# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

{/* step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Allow extra response fields

// (test {"testId":"http-request-additional-fields-true","detectSteps":true})

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

// (step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Allow extra response fields</title></head>
<body>
<!-- test {"testId":"http-request-additional-fields-true","detectSteps":true} -->
<h1>Allow extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8092/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds <code>name</code> and an extra field.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Allow extra response fields
===========================

.. test {"testId":"http-request-additional-fields-true","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8092/api/users`` with the body ``{"name": "Ada"}``. The response holds ``name`` and an extra field.

.. step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}}

.. 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="http-request-additional-fields-true">
  <title>Allow extra response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-additional-fields-true","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds <codeph>name</codeph> and an extra field.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-additional-fields-true","detectSteps":false} -->

# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-additional-fields-true","detectSteps":false} */}

# Allow extra response fields

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

{/* step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Allow extra response fields

// (test {"testId":"http-request-additional-fields-true","detectSteps":false})

Send a `POST` request to `http://localhost:8092/api/users` with the body `{"name": "Ada"}`. The response holds `name` and an extra field.

// (step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Allow extra response fields</title></head>
<body>
<!-- test {"testId":"http-request-additional-fields-true","detectSteps":false} -->
<h1>Allow extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8092/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds <code>name</code> and an extra field.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Allow extra response fields
===========================

.. test {"testId":"http-request-additional-fields-true","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8092/api/users`` with the body ``{"name": "Ada"}``. The response holds ``name`` and an extra field.

.. step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":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="http-request-additional-fields-true">
  <title>Allow extra response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-additional-fields-true","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8092/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds <codeph>name</codeph> and an extra field.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":true}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-additional-fields-true",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/api/users",
            "method": "post",
            "request": {
              "body": {
                "name": "Ada"
              }
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            },
            "allowAdditionalFields": 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
tests:
  - testId: http-request-additional-fields-true
    steps:
      - httpRequest:
          url: http://localhost:8092/api/users
          method: post
          request:
            body:
              name: Ada
          response:
            body:
              name: Ada
          allowAdditionalFields: true
```

### `allowAdditionalFields: false`

**Varies:** `httpRequest.allowAdditionalFields` · **Value:** `false` · **Effect:** fails when the response holds a field that `response.body` doesn't list, so this step calls the `8093` server, which adds none.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Reject extra response fields</title></head>
<body>
<h1>Reject extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds only <code>name</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Reject extra response fields
============================

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name": "Ada"}``. The response holds only ``name``.
```

#### 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="http-request-additional-fields-false">
  <title>Reject extra response fields</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds only <codeph>name</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-additional-fields-false","detectSteps":true} -->

# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-additional-fields-false","detectSteps":true} */}

# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Reject extra response fields

// (test {"testId":"http-request-additional-fields-false","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Reject extra response fields</title></head>
<body>
<!-- test {"testId":"http-request-additional-fields-false","detectSteps":true} -->
<h1>Reject extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds only <code>name</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Reject extra response fields
============================

.. test {"testId":"http-request-additional-fields-false","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name": "Ada"}``. The response holds only ``name``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}}

.. 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="http-request-additional-fields-false">
  <title>Reject extra response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-additional-fields-false","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds only <codeph>name</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-additional-fields-false","detectSteps":false} -->

# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-additional-fields-false","detectSteps":false} */}

# Reject extra response fields

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Reject extra response fields

// (test {"testId":"http-request-additional-fields-false","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/users` with the body `{"name": "Ada"}`. The response holds only `name`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Reject extra response fields</title></head>
<body>
<!-- test {"testId":"http-request-additional-fields-false","detectSteps":false} -->
<h1>Reject extra response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/users</code> with the body <code>{"name": "Ada"}</code>. The response holds only <code>name</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Reject extra response fields
============================

.. test {"testId":"http-request-additional-fields-false","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/users`` with the body ``{"name": "Ada"}``. The response holds only ``name``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}}

.. 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="http-request-additional-fields-false">
  <title>Reject extra response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-additional-fields-false","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/users</codeph> with the body <codeph>{"name": "Ada"}</codeph>. The response holds only <codeph>name</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users","method":"post","request":{"body":{"name":"Ada"}},"response":{"body":{"name":"Ada"}},"allowAdditionalFields":false}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-additional-fields-false",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users",
            "method": "post",
            "request": {
              "body": {
                "name": "Ada"
              }
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            },
            "allowAdditionalFields": false
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-additional-fields-false
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users
          method: post
          request:
            body:
              name: Ada
          response:
            body:
              name: Ada
          allowAdditionalFields: false
```

### `response.body` as a string

**Varies:** `httpRequest.response.body` · **Value:** `"Cookie set."` · **Effect:** compares a text response with the string.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a text response</title></head>
<body>
<h1>Expect a text response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/cookies/set/theme/dark</code>. The response is the text <code>Cookie set.</code></p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Expect a text response
======================

Send a ``GET`` request to ``http://localhost:8092/cookies/set/theme/dark``. The response is the text ``Cookie set.``
```

#### 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="http-request-response-string">
  <title>Expect a text response</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/cookies/set/theme/dark</codeph>. The response is the text <codeph>Cookie set.</codeph></p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

<!-- step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-response-string","detectSteps":true} */}

# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

{/* step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Expect a text response

// (test {"testId":"http-request-response-string","detectSteps":true})

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

// (step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a text response</title></head>
<body>
<!-- test {"testId":"http-request-response-string","detectSteps":true} -->
<h1>Expect a text response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/cookies/set/theme/dark</code>. The response is the text <code>Cookie set.</code></p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Expect a text response
======================

.. test {"testId":"http-request-response-string","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8092/cookies/set/theme/dark``. The response is the text ``Cookie set.``

.. step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}}

.. 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="http-request-response-string">
  <title>Expect a text response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-string","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/cookies/set/theme/dark</codeph>. The response is the text <codeph>Cookie set.</codeph></p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

<!-- step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-response-string","detectSteps":false} */}

# Expect a text response

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

{/* step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Expect a text response

// (test {"testId":"http-request-response-string","detectSteps":false})

Send a `GET` request to `http://localhost:8092/cookies/set/theme/dark`. The response is the text `Cookie set.`

// (step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a text response</title></head>
<body>
<!-- test {"testId":"http-request-response-string","detectSteps":false} -->
<h1>Expect a text response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8092/cookies/set/theme/dark</code>. The response is the text <code>Cookie set.</code></p>
<!-- step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Expect a text response
======================

.. test {"testId":"http-request-response-string","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8092/cookies/set/theme/dark``. The response is the text ``Cookie set.``

.. step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}}

.. 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="http-request-response-string">
  <title>Expect a text response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-string","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8092/cookies/set/theme/dark</codeph>. The response is the text <codeph>Cookie set.</codeph></p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8092/cookies/set/theme/dark","response":{"body":"Cookie set."}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-response-string",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8092/cookies/set/theme/dark",
            "response": {
              "body": "Cookie set."
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-response-string
    steps:
      - httpRequest:
          url: http://localhost:8092/cookies/set/theme/dark
          response:
            body: Cookie set.
```

### `response.required`

**Varies:** `httpRequest.response.required` · **Value:** `["user.name", "items[0].id"]` · **Effect:** fails unless each field path exists in the response, whatever its value.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Require nested response fields</title></head>
<body>
<h1>Require nested response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/orders</code> with a user and one item. The response has <code>user.name</code> and <code>items[0].id</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Require nested response fields
==============================

Send a ``POST`` request to ``http://localhost:8093/api/orders`` with a user and one item. The response has ``user.name`` and ``items[0].id``.
```

#### 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="http-request-response-required">
  <title>Require nested response fields</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/orders</codeph> with a user and one item. The response has <codeph>user.name</codeph> and <codeph>items[0].id</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-response-required","detectSteps":true} */}

# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Require nested response fields

// (test {"testId":"http-request-response-required","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Require nested response fields</title></head>
<body>
<!-- test {"testId":"http-request-response-required","detectSteps":true} -->
<h1>Require nested response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/orders</code> with a user and one item. The response has <code>user.name</code> and <code>items[0].id</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Require nested response fields
==============================

.. test {"testId":"http-request-response-required","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/orders`` with a user and one item. The response has ``user.name`` and ``items[0].id``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}}

.. 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="http-request-response-required">
  <title>Require nested response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-required","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/orders</codeph> with a user and one item. The response has <codeph>user.name</codeph> and <codeph>items[0].id</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-response-required","detectSteps":false} */}

# Require nested response fields

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Require nested response fields

// (test {"testId":"http-request-response-required","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/orders` with a user and one item. The response has `user.name` and `items[0].id`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Require nested response fields</title></head>
<body>
<!-- test {"testId":"http-request-response-required","detectSteps":false} -->
<h1>Require nested response fields</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/orders</code> with a user and one item. The response has <code>user.name</code> and <code>items[0].id</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Require nested response fields
==============================

.. test {"testId":"http-request-response-required","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/orders`` with a user and one item. The response has ``user.name`` and ``items[0].id``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}}

.. 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="http-request-response-required">
  <title>Require nested response fields</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-required","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/orders</codeph> with a user and one item. The response has <codeph>user.name</codeph> and <codeph>items[0].id</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/orders","method":"post","request":{"body":{"user":{"name":"Ada"},"items":[{"id":"inv-1"}]}},"response":{"required":["user.name","items[0].id"]}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-response-required",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/orders",
            "method": "post",
            "request": {
              "body": {
                "user": {
                  "name": "Ada"
                },
                "items": [
                  {
                    "id": "inv-1"
                  }
                ]
              }
            },
            "response": {
              "required": [
                "user.name",
                "items[0].id"
              ]
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-response-required
    steps:
      - httpRequest:
          url: http://localhost:8093/api/orders
          method: post
          request:
            body:
              user:
                name: Ada
              items:
                - id: inv-1
          response:
            required:
              - user.name
              - items[0].id
```

### `response.schema`

**Varies:** `httpRequest.response.schema` · **Value:** a JSON Schema with `format: uuid`, `format: date-time`, and a `pattern` · **Effect:** fails unless the response body matches the schema's types, formats, and patterns.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match the response to a schema</title></head>
<body>
<h1>Match the response to a schema</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/invoices</code> with an invoice. In the response, <code>id</code> is a UUID, <code>created</code> is a date-time, <code>code</code> matches <code>^INV-[0-9]+$</code>, and <code>total</code> is a number.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Match the response to a schema
==============================

Send a ``POST`` request to ``http://localhost:8093/api/invoices`` with an invoice. In the response, ``id`` is a UUID, ``created`` is a date-time, ``code`` matches ``^INV-[0-9]+$``, and ``total`` is a number.
```

#### 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="http-request-response-schema">
  <title>Match the response to a schema</title>
  <body>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/invoices</codeph> with an invoice. In the response, <codeph>id</codeph> is a UUID, <codeph>created</codeph> is a date-time, <codeph>code</codeph> matches <codeph>^INV-[0-9]+$</codeph>, and <codeph>total</codeph> is a number.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-response-schema","detectSteps":true} */}

# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Match the response to a schema

// (test {"testId":"http-request-response-schema","detectSteps":true})

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

// (step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match the response to a schema</title></head>
<body>
<!-- test {"testId":"http-request-response-schema","detectSteps":true} -->
<h1>Match the response to a schema</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/invoices</code> with an invoice. In the response, <code>id</code> is a UUID, <code>created</code> is a date-time, <code>code</code> matches <code>^INV-[0-9]+$</code>, and <code>total</code> is a number.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Match the response to a schema
==============================

.. test {"testId":"http-request-response-schema","detectSteps":true}

Send a ``POST`` request to ``http://localhost:8093/api/invoices`` with an invoice. In the response, ``id`` is a UUID, ``created`` is a date-time, ``code`` matches ``^INV-[0-9]+$``, and ``total`` is a number.

.. step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}}

.. 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="http-request-response-schema">
  <title>Match the response to a schema</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-schema","detectSteps":true}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/invoices</codeph> with an invoice. In the response, <codeph>id</codeph> is a UUID, <codeph>created</codeph> is a date-time, <codeph>code</codeph> matches <codeph>^INV-[0-9]+$</codeph>, and <codeph>total</codeph> is a number.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-response-schema","detectSteps":false} */}

# Match the response to a schema

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Match the response to a schema

// (test {"testId":"http-request-response-schema","detectSteps":false})

Send a `POST` request to `http://localhost:8093/api/invoices` with an invoice. In the response, `id` is a UUID, `created` is a date-time, `code` matches `^INV-[0-9]+$`, and `total` is a number.

// (step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match the response to a schema</title></head>
<body>
<!-- test {"testId":"http-request-response-schema","detectSteps":false} -->
<h1>Match the response to a schema</h1>
<p>Send a <code>POST</code> request to <code>http://localhost:8093/api/invoices</code> with an invoice. In the response, <code>id</code> is a UUID, <code>created</code> is a date-time, <code>code</code> matches <code>^INV-[0-9]+$</code>, and <code>total</code> is a number.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Match the response to a schema
==============================

.. test {"testId":"http-request-response-schema","detectSteps":false}

Send a ``POST`` request to ``http://localhost:8093/api/invoices`` with an invoice. In the response, ``id`` is a UUID, ``created`` is a date-time, ``code`` matches ``^INV-[0-9]+$``, and ``total`` is a number.

.. step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}}

.. 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="http-request-response-schema">
  <title>Match the response to a schema</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-response-schema","detectSteps":false}'/>
    <p>Send a <codeph>POST</codeph> request to <codeph>http://localhost:8093/api/invoices</codeph> with an invoice. In the response, <codeph>id</codeph> is a UUID, <codeph>created</codeph> is a date-time, <codeph>code</codeph> matches <codeph>^INV-[0-9]+$</codeph>, and <codeph>total</codeph> is a number.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/invoices","method":"post","request":{"body":{"id":"3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b","created":"2026-11-26T10:00:00Z","code":"INV-1042","total":19.99}},"response":{"schema":{"type":"object","required":["id","created","code","total"],"properties":{"id":{"type":"string","format":"uuid"},"created":{"type":"string","format":"date-time"},"code":{"type":"string","pattern":"^INV-[0-9]+$"},"total":{"type":"number"}}}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-response-schema",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/invoices",
            "method": "post",
            "request": {
              "body": {
                "id": "3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b",
                "created": "2026-11-26T10:00:00Z",
                "code": "INV-1042",
                "total": 19.99
              }
            },
            "response": {
              "schema": {
                "type": "object",
                "required": [
                  "id",
                  "created",
                  "code",
                  "total"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "created": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^INV-[0-9]+$"
                  },
                  "total": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-response-schema
    steps:
      - httpRequest:
          url: http://localhost:8093/api/invoices
          method: post
          request:
            body:
              id: 3f2b8c1e-9a4d-4e6f-8b1a-2c3d4e5f6a7b
              created: "2026-11-26T10:00:00Z"
              code: INV-1042
              total: 19.99
          response:
            schema:
              type: object
              required:
                - id
                - created
                - code
                - total
              properties:
                id:
                  type: string
                  format: uuid
                created:
                  type: string
                  format: date-time
                code:
                  type: string
                  pattern: "^INV-[0-9]+$"
                total:
                  type: number
```

### `overwrite: "true"`

**Varies:** `httpRequest.overwrite` · **Value:** `true` · **Effect:** saves the response to `page-2.json` next to the test file. Replaces `page-2.json` with each new response.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save a response
===============

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.
```

#### 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="http-request-overwrite-true">
  <title>Save a response</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-overwrite-true","detectSteps":true} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-overwrite-true","detectSteps":true} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-true","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-true","detectSteps":true} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-true","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}}

.. 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="http-request-overwrite-true">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-true","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-overwrite-true","detectSteps":false} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-overwrite-true","detectSteps":false} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-true","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-true","detectSteps":false} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-true","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"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="http-request-overwrite-true">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-true","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"true"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-overwrite-true",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "path": "page-2.json",
            "overwrite": "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
tests:
  - testId: http-request-overwrite-true
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          path: page-2.json
          overwrite: "true"
```

### `overwrite: "false"`

**Varies:** `httpRequest.overwrite` · **Value:** `false` · **Effect:** saves the response to `page-2.json` next to the test file. Keeps `page-2.json` as is, and returns a warning when a response differs from it.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save a response
===============

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.
```

#### 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="http-request-overwrite-false">
  <title>Save a response</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-overwrite-false","detectSteps":true} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-overwrite-false","detectSteps":true} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-false","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-false","detectSteps":true} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-false","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}}

.. 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="http-request-overwrite-false">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-false","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-overwrite-false","detectSteps":false} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-overwrite-false","detectSteps":false} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-false","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-false","detectSteps":false} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-false","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}}

.. 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="http-request-overwrite-false">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-false","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"false"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-overwrite-false",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "path": "page-2.json",
            "overwrite": "false"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-overwrite-false
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          path: page-2.json
          overwrite: "false"
```

### `overwrite: "aboveVariation"`

**Varies:** `httpRequest.overwrite` · **Value:** `aboveVariation` · **Effect:** saves the response to `page-2.json` next to the test file. Replaces `page-2.json` only when a response differs by more than `maxVariation`, 10% here.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save a response
===============

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.
```

#### 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="http-request-overwrite-abovevariation">
  <title>Save a response</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-overwrite-abovevariation","detectSteps":true} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-overwrite-abovevariation","detectSteps":true} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-abovevariation","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-abovevariation","detectSteps":true} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-abovevariation","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}}

.. 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="http-request-overwrite-abovevariation">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-abovevariation","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-overwrite-abovevariation","detectSteps":false} -->

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-overwrite-abovevariation","detectSteps":false} */}

# Save a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save a response

// (test {"testId":"http-request-overwrite-abovevariation","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users?page=2`, and save the response to `page-2.json`.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a response</title></head>
<body>
<!-- test {"testId":"http-request-overwrite-abovevariation","detectSteps":false} -->
<h1>Save a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>, and save the response to <code>page-2.json</code>.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save a response
===============

.. test {"testId":"http-request-overwrite-abovevariation","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``, and save the response to ``page-2.json``.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}}

.. 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="http-request-overwrite-abovevariation">
  <title>Save a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-overwrite-abovevariation","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>, and save the response to <codeph>page-2.json</codeph>.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","path":"page-2.json","overwrite":"aboveVariation","maxVariation":0.1}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-overwrite-abovevariation",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "path": "page-2.json",
            "overwrite": "aboveVariation",
            "maxVariation": 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: http-request-overwrite-abovevariation
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          path: page-2.json
          overwrite: aboveVariation
          maxVariation: 0.1
```

### `timeout`

**Varies:** `httpRequest.timeout` · **Value:** `5000` · **Effect:** fails the step when the response takes longer than 5 seconds.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Limit the wait for a response</title></head>
<body>
<h1>Limit the wait for a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>. The API answers within 5 seconds.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Limit the wait for a response
=============================

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``. The API answers within 5 seconds.
```

#### 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="http-request-timeout">
  <title>Limit the wait for a response</title>
  <body>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>. The API answers within 5 seconds.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-request-timeout","detectSteps":true} -->

# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-request-timeout","detectSteps":true} */}

# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Limit the wait for a response

// (test {"testId":"http-request-timeout","detectSteps":true})

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Limit the wait for a response</title></head>
<body>
<!-- test {"testId":"http-request-timeout","detectSteps":true} -->
<h1>Limit the wait for a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>. The API answers within 5 seconds.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Limit the wait for a response
=============================

.. test {"testId":"http-request-timeout","detectSteps":true}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``. The API answers within 5 seconds.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}}

.. 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="http-request-timeout">
  <title>Limit the wait for a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-timeout","detectSteps":true}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>. The API answers within 5 seconds.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-request-timeout","detectSteps":false} -->

# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-request-timeout","detectSteps":false} */}

# Limit the wait for a response

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Limit the wait for a response

// (test {"testId":"http-request-timeout","detectSteps":false})

Send a `GET` request to `http://localhost:8093/api/users?page=2`. The API answers within 5 seconds.

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Limit the wait for a response</title></head>
<body>
<!-- test {"testId":"http-request-timeout","detectSteps":false} -->
<h1>Limit the wait for a response</h1>
<p>Send a <code>GET</code> request to <code>http://localhost:8093/api/users?page=2</code>. The API answers within 5 seconds.</p>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Limit the wait for a response
=============================

.. test {"testId":"http-request-timeout","detectSteps":false}

Send a ``GET`` request to ``http://localhost:8093/api/users?page=2``. The API answers within 5 seconds.

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}}

.. 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="http-request-timeout">
  <title>Limit the wait for a response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-timeout","detectSteps":false}'/>
    <p>Send a <codeph>GET</codeph> request to <codeph>http://localhost:8093/api/users?page=2</codeph>. The API answers within 5 seconds.</p>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","timeout":5000}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-timeout",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "timeout": 5000
          }
        }
      ]
    }
  ]
}
```

#### 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: http-request-timeout
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          timeout: 5000
```

### Code block tagged `http`

**Varies:** `codeBlock.language` · **Value:** `http` · **Effect:** detection turns the raw request in the block into an `httpRequest` step.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a raw HTTP request

Send this request:

[source,http]
----
GET http://localhost:8093/api/users?page=2 HTTP/1.1
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw HTTP request</title></head>
<body>
<h1>Send a raw HTTP request</h1>
<p>Send this request:</p>
<pre><code class="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a raw HTTP request
=======================

Send this request:

.. code-block:: http

   GET http://localhost:8093/api/users?page=2 HTTP/1.1
```

#### 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="http-request-block-http">
  <title>Send a raw HTTP request</title>
  <body>
    <p>Send this request:</p>
    <codeblock outputclass="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-request-block-http","detectSteps":true} -->

# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-request-block-http","detectSteps":true} */}

# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a raw HTTP request

// (test {"testId":"http-request-block-http","detectSteps":true})

Send this request:

[source,http]
----
GET http://localhost:8093/api/users?page=2 HTTP/1.1
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw HTTP request</title></head>
<body>
<!-- test {"testId":"http-request-block-http","detectSteps":true} -->
<h1>Send a raw HTTP request</h1>
<p>Send this request:</p>
<pre><code class="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a raw HTTP request
=======================

.. test {"testId":"http-request-block-http","detectSteps":true}

Send this request:

.. code-block:: http

   GET http://localhost:8093/api/users?page=2 HTTP/1.1

.. 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="http-request-block-http">
  <title>Send a raw HTTP request</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-block-http","detectSteps":true}'/>
    <p>Send this request:</p>
    <codeblock outputclass="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-request-block-http","detectSteps":false} -->

# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-request-block-http","detectSteps":false} */}

# Send a raw HTTP request

Send this request:

```http
GET http://localhost:8093/api/users?page=2 HTTP/1.1
```

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a raw HTTP request

// (test {"testId":"http-request-block-http","detectSteps":false})

Send this request:

[source,http]
----
GET http://localhost:8093/api/users?page=2 HTTP/1.1
----

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw HTTP request</title></head>
<body>
<!-- test {"testId":"http-request-block-http","detectSteps":false} -->
<h1>Send a raw HTTP request</h1>
<p>Send this request:</p>
<pre><code class="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</code></pre>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a raw HTTP request
=======================

.. test {"testId":"http-request-block-http","detectSteps":false}

Send this request:

.. code-block:: http

   GET http://localhost:8093/api/users?page=2 HTTP/1.1

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}}

.. 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="http-request-block-http">
  <title>Send a raw HTTP request</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-block-http","detectSteps":false}'/>
    <p>Send this request:</p>
    <codeblock outputclass="language-http">GET http://localhost:8093/api/users?page=2 HTTP/1.1</codeblock>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-block-http",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "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: http-request-block-http
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          method: get
```

### Code block with no language

**Varies:** `codeBlock.language` · **Value:** `(none)` · **Effect:** detection also reads a raw request from a block with no language.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Send a raw request from a plain block

Send this request:

----
GET http://localhost:8093/api/users?page=2
X-Test: docs
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw request from a plain block</title></head>
<body>
<h1>Send a raw request from a plain block</h1>
<p>Send this request:</p>
<pre><code>GET http://localhost:8093/api/users?page=2
X-Test: docs</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Send a raw request from a plain block
=====================================

Send this request::

   GET http://localhost:8093/api/users?page=2
   X-Test: docs
```

#### 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="http-request-block-untagged">
  <title>Send a raw request from a plain block</title>
  <body>
    <p>Send this request:</p>
    <codeblock>GET http://localhost:8093/api/users?page=2
X-Test: docs</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-request-block-untagged","detectSteps":true} -->

# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-request-block-untagged","detectSteps":true} */}

# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Send a raw request from a plain block

// (test {"testId":"http-request-block-untagged","detectSteps":true})

Send this request:

----
GET http://localhost:8093/api/users?page=2
X-Test: docs
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw request from a plain block</title></head>
<body>
<!-- test {"testId":"http-request-block-untagged","detectSteps":true} -->
<h1>Send a raw request from a plain block</h1>
<p>Send this request:</p>
<pre><code>GET http://localhost:8093/api/users?page=2
X-Test: docs</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Send a raw request from a plain block
=====================================

.. test {"testId":"http-request-block-untagged","detectSteps":true}

Send this request::

   GET http://localhost:8093/api/users?page=2
   X-Test: docs

.. 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="http-request-block-untagged">
  <title>Send a raw request from a plain block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-block-untagged","detectSteps":true}'/>
    <p>Send this request:</p>
    <codeblock>GET http://localhost:8093/api/users?page=2
X-Test: docs</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-request-block-untagged","detectSteps":false} -->

# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```

<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-request-block-untagged","detectSteps":false} */}

# Send a raw request from a plain block

Send this request:

```
GET http://localhost:8093/api/users?page=2
X-Test: docs
```

{/* step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Send a raw request from a plain block

// (test {"testId":"http-request-block-untagged","detectSteps":false})

Send this request:

----
GET http://localhost:8093/api/users?page=2
X-Test: docs
----

// (step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Send a raw request from a plain block</title></head>
<body>
<!-- test {"testId":"http-request-block-untagged","detectSteps":false} -->
<h1>Send a raw request from a plain block</h1>
<p>Send this request:</p>
<pre><code>GET http://localhost:8093/api/users?page=2
X-Test: docs</code></pre>
<!-- step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Send a raw request from a plain block
=====================================

.. test {"testId":"http-request-block-untagged","detectSteps":false}

Send this request::

   GET http://localhost:8093/api/users?page=2
   X-Test: docs

.. step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}}

.. 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="http-request-block-untagged">
  <title>Send a raw request from a plain block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-request-block-untagged","detectSteps":false}'/>
    <p>Send this request:</p>
    <codeblock>GET http://localhost:8093/api/users?page=2
X-Test: docs</codeblock>
    <data name="doc-detective" value='step {"httpRequest":{"url":"http://localhost:8093/api/users?page=2","method":"get","request":{"headers":{"X-Test":"docs"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-request-block-untagged",
      "steps": [
        {
          "httpRequest": {
            "url": "http://localhost:8093/api/users?page=2",
            "method": "get",
            "request": {
              "headers": {
                "X-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: http-request-block-untagged
    steps:
      - httpRequest:
          url: http://localhost:8093/api/users?page=2
          method: get
          request:
            headers:
              X-Test: docs
```

## `openApi` permutations

These examples load `users.openapi.json` from the [OpenAPI example](#call-operations-from-an-openapi-description). Its `createUser` operation requires `name` and `job`, and its servers list points at the `8093` echo API.

### `openApi` as a string

**Varies:** `httpRequest.openApi` · **Value:** `"createUser"` · **Effect:** looks up the operation by ID in the test's descriptions, and takes its method, URL, and schemas from it.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation by ID

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation by ID

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation by ID

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation by ID</title></head>
<body>
<h1>Call an operation by ID</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation by ID
=======================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-operation-string">
  <title>Call an operation by ID</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation by ID

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation by ID

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation by ID

// (test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation by ID</title></head>
<body>
<!-- test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation by ID</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation by ID
=======================

.. test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-operation-string">
  <title>Call an operation by ID</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-operation-string","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation by ID

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation by ID

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation by ID

// (test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation by ID</title></head>
<body>
<!-- test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation by ID</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation by ID
=======================

.. test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-operation-string">
  <title>Call an operation by ID</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-operation-string","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-operation-string",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": "createUser",
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-operation-string
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi: createUser
          request:
            body:
              name: Ada
              job: engineer
          response:
            body:
              name: Ada
```

### `openApi` as an object

**Varies:** `httpRequest.openApi` · **Value:** `{"operationId": "createUser"}` · **Effect:** does the same as the string form, and leaves room for options such as `useExample`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation with options

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation with options

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation with options

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with options</title></head>
<body>
<h1>Call an operation with options</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation with options
==============================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-operation-object">
  <title>Call an operation with options</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with options

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with options

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation with options

// (test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with options</title></head>
<body>
<!-- test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with options</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation with options
==============================

.. test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-operation-object">
  <title>Call an operation with options</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-operation-object","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with options

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with options

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation with options

// (test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with options</title></head>
<body>
<!-- test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with options</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation with options
==============================

.. test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-operation-object">
  <title>Call an operation with options</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-operation-object","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-operation-object",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-operation-object
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
          request:
            body:
              name: Ada
              job: engineer
          response:
            body:
              name: Ada
```

### `useExample: "none"`

**Varies:** `httpRequest.openApi.useExample` · **Value:** `none` · **Effect:** uses only the request and response the step sets.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation with its examples
===================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-useexample-none">
  <title>Call an operation with its examples</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-useexample-none">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-useexample-none">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"none"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-useexample-none",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "useExample": "none"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-useexample-none
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            useExample: none
          request:
            body:
              name: Ada
              job: engineer
```

### `useExample: "request"`

**Varies:** `httpRequest.openApi.useExample` · **Value:** `request` · **Effect:** sends the operation's request example, so the step sets no body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation with its examples
===================================

Call the ``createUser`` operation with its example user.
```

#### 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="http-openapi-useexample-request">
  <title>Call an operation with its examples</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with its example user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with its example user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with its example user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with its example user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}}

.. 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="http-openapi-useexample-request">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with its example user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with its example user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with its example user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with its example user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}}

.. 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="http-openapi-useexample-request">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"request"}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-useexample-request",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "useExample": "request"
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-useexample-request
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            useExample: request
```

### `useExample: "response"`

**Varies:** `httpRequest.openApi.useExample` · **Value:** `response` · **Effect:** checks the response against the operation's response example.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation with its examples

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation with its examples
===================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-useexample-response">
  <title>Call an operation with its examples</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-useexample-response">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-useexample-response">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-useexample-response",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "useExample": "response"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-useexample-response
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            useExample: response
          request:
            body:
              name: Ada
              job: engineer
```

### `useExample: "both"`

**Varies:** `httpRequest.openApi.useExample` · **Value:** `both` · **Effect:** sends the request example and checks the response against the response example.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Call an operation with its examples

Call the `createUser` operation with its example user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Call an operation with its examples
===================================

Call the ``createUser`` operation with its example user.
```

#### 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="http-openapi-useexample-both">
  <title>Call an operation with its examples</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with its example user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with its example user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with its example user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with its example user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}}

.. 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="http-openapi-useexample-both">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Call an operation with its examples

Call the `createUser` operation with its example user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Call an operation with its examples

Call the `createUser` operation with its example user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Call an operation with its examples

// (test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with its example user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Call an operation with its examples</title></head>
<body>
<!-- test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Call an operation with its examples</h1>
<p>Call the <code>createUser</code> operation with its example user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Call an operation with its examples
===================================

.. test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with its example user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}}

.. 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="http-openapi-useexample-both">
  <title>Call an operation with its examples</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-useexample-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with its example user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","useExample":"both"}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-useexample-both",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "useExample": "both"
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-useexample-both
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            useExample: both
```

### `mockResponse: true`

**Varies:** `httpRequest.openApi.mockResponse` · **Value:** `true` · **Effect:** sends no request, and uses the operation's response example as the response.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Preview an operation's response

Preview the `getUser` response from its `ada` example.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Preview an operation's response

Preview the `getUser` response from its `ada` example.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Preview an operation's response

Preview the `getUser` response from its `ada` example.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview an operation's response</title></head>
<body>
<h1>Preview an operation's response</h1>
<p>Preview the <code>getUser</code> response from its <code>ada</code> example.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Preview an operation's response
===============================

Preview the ``getUser`` response from its ``ada`` example.
```

#### 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="http-openapi-mockresponse">
  <title>Preview an operation's response</title>
  <body>
    <p>Preview the <codeph>getUser</codeph> response from its <codeph>ada</codeph> example.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Preview an operation's response

Preview the `getUser` response from its `ada` example.

<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Preview an operation's response

Preview the `getUser` response from its `ada` example.

{/* step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Preview an operation's response

// (test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Preview the `getUser` response from its `ada` example.

// (step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview an operation's response</title></head>
<body>
<!-- test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Preview an operation's response</h1>
<p>Preview the <code>getUser</code> response from its <code>ada</code> example.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Preview an operation's response
===============================

.. test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Preview the ``getUser`` response from its ``ada`` example.

.. step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-mockresponse">
  <title>Preview an operation's response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-mockresponse","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Preview the <codeph>getUser</codeph> response from its <codeph>ada</codeph> example.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Preview an operation's response

Preview the `getUser` response from its `ada` example.

<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Preview an operation's response

Preview the `getUser` response from its `ada` example.

{/* step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Preview an operation's response

// (test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Preview the `getUser` response from its `ada` example.

// (step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Preview an operation's response</title></head>
<body>
<!-- test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Preview an operation's response</h1>
<p>Preview the <code>getUser</code> response from its <code>ada</code> example.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Preview an operation's response
===============================

.. test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Preview the ``getUser`` response from its ``ada`` example.

.. step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-mockresponse">
  <title>Preview an operation's response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-mockresponse","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Preview the <codeph>getUser</codeph> response from its <codeph>ada</codeph> example.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"getUser","mockResponse":true,"useExample":"response","exampleKey":"ada","validateAgainstSchema":"response"},"response":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-mockresponse",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "getUser",
              "mockResponse": true,
              "useExample": "response",
              "exampleKey": "ada",
              "validateAgainstSchema": "response"
            },
            "response": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-mockresponse
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: getUser
            mockResponse: true
            useExample: response
            exampleKey: ada
            validateAgainstSchema: response
          response:
            body:
              name: Ada
```

### `validateAgainstSchema: "both"`

**Varies:** `httpRequest.openApi.validateAgainstSchema` · **Value:** `both` · **Effect:** validates the request and the response against the operation's schemas.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Validate against the description
================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-validate-both">
  <title>Validate against the description</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-both">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-both","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-both">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-both","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"both"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-validate-both",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "validateAgainstSchema": "both"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-validate-both
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            validateAgainstSchema: both
          request:
            body:
              name: Ada
              job: engineer
```

### `validateAgainstSchema: "request"`

**Varies:** `httpRequest.openApi.validateAgainstSchema` · **Value:** `request` · **Effect:** validates only the request body against the schema.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Validate against the description
================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-validate-request">
  <title>Validate against the description</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-request">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-request","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-request">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-request","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"request"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-validate-request",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "validateAgainstSchema": "request"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-validate-request
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            validateAgainstSchema: request
          request:
            body:
              name: Ada
              job: engineer
```

### `validateAgainstSchema: "response"`

**Varies:** `httpRequest.openApi.validateAgainstSchema` · **Value:** `response` · **Effect:** validates only the response body against the schema.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Validate against the description

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Validate against the description
================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-validate-response">
  <title>Validate against the description</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-response">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-response","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-validate-response">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-response","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"response"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-validate-response",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "validateAgainstSchema": "response"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-validate-response
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            validateAgainstSchema: response
          request:
            body:
              name: Ada
              job: engineer
```

### `validateAgainstSchema: "none"`

**Varies:** `httpRequest.openApi.validateAgainstSchema` · **Value:** `none` · **Effect:** skips validation, so a body without the required `job` field passes.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Validate against the description

Call the `createUser` operation with only a name.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Validate against the description

Call the `createUser` operation with only a name.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Validate against the description

Call the `createUser` operation with only a name.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with only a name.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Validate against the description
================================

Call the ``createUser`` operation with only a name.
```

#### 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="http-openapi-validate-none">
  <title>Validate against the description</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with only a name.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with only a name.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with only a name.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with only a name.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with only a name.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with only a name.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-validate-none">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-none","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with only a name.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Validate against the description

Call the `createUser` operation with only a name.

<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Validate against the description

Call the `createUser` operation with only a name.

{/* step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Validate against the description

// (test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with only a name.

// (step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Validate against the description</title></head>
<body>
<!-- test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Validate against the description</h1>
<p>Call the <code>createUser</code> operation with only a name.</p>
<!-- step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Validate against the description
================================

.. test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with only a name.

.. step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}}

.. 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="http-openapi-validate-none">
  <title>Validate against the description</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-validate-none","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with only a name.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"operationId":"createUser","validateAgainstSchema":"none"},"request":{"body":{"name":"Ada"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-validate-none",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "operationId": "createUser",
              "validateAgainstSchema": "none"
            },
            "request": {
              "body": {
                "name": "Ada"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-validate-none
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi:
            operationId: createUser
            validateAgainstSchema: none
          request:
            body:
              name: Ada
```

### Description on the spec

**Varies:** `spec.openApi` · **Value:** `[{"name": "users", ...}]` · **Effect:** every test in the spec can call the description's operations. Inline tests have no spec, so their `test` statement holds the list.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Share a description across tests

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Share a description across tests

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Share a description across tests

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Share a description across tests</title></head>
<body>
<h1>Share a description across tests</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Share a description across tests
================================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-level-spec">
  <title>Share a description across tests</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Share a description across tests

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Share a description across tests

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Share a description across tests

// (test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Share a description across tests</title></head>
<body>
<!-- test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Share a description across tests</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Share a description across tests
================================

.. test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-spec">
  <title>Share a description across tests</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-spec","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Share a description across tests

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Share a description across tests

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Share a description across tests

// (test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Share a description across tests</title></head>
<body>
<!-- test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Share a description across tests</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Share a description across tests
================================

.. test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-spec">
  <title>Share a description across tests</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-spec","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "openApi": [
    {
      "name": "users",
      "descriptionPath": "../http-openapi/users.openapi.json"
    }
  ],
  "tests": [
    {
      "testId": "http-openapi-level-spec",
      "steps": [
        {
          "httpRequest": {
            "openApi": "createUser",
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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
openApi:
  - name: users
    descriptionPath: ../http-openapi/users.openapi.json
tests:
  - testId: http-openapi-level-spec
    steps:
      - httpRequest:
          openApi: createUser
          request:
            body:
              name: Ada
              job: engineer
```

### Description on the test

**Varies:** `test.openApi` · **Value:** `[{"name": "users", ...}]` · **Effect:** only this test can call the description's operations.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Load a description for one test

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Load a description for one test

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Load a description for one test

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description for one test</title></head>
<body>
<h1>Load a description for one test</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Load a description for one test
===============================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-level-test">
  <title>Load a description for one test</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Load a description for one test

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Load a description for one test

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Load a description for one test

// (test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description for one test</title></head>
<body>
<!-- test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Load a description for one test</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Load a description for one test
===============================

.. test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-test">
  <title>Load a description for one test</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-test","detectSteps":true,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->

# Load a description for one test

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} */}

# Load a description for one test

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Load a description for one test

// (test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description for one test</title></head>
<body>
<!-- test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]} -->
<h1>Load a description for one test</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Load a description for one test
===============================

.. test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-test">
  <title>Load a description for one test</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-test","detectSteps":false,"openApi":[{"name":"users","descriptionPath":"../http-openapi/users.openapi.json"}]}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":"createUser","request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-level-test",
      "openApi": [
        {
          "name": "users",
          "descriptionPath": "../http-openapi/users.openapi.json"
        }
      ],
      "steps": [
        {
          "httpRequest": {
            "openApi": "createUser",
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-level-test
    openApi:
      - name: users
        descriptionPath: ../http-openapi/users.openapi.json
    steps:
      - httpRequest:
          openApi: createUser
          request:
            body:
              name: Ada
              job: engineer
```

### Description on the step

**Varies:** `httpRequest.openApi.descriptionPath` · **Value:** `"../http-openapi/users.openapi.json"` · **Effect:** loads the description for this step only, with no `openApi` list on the test or spec.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Load a description in the step

Call the `createUser` operation with Ada as the user.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Load a description in the step

Call the `createUser` operation with Ada as the user.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Load a description in the step

Call the `createUser` operation with Ada as the user.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description in the step</title></head>
<body>
<h1>Load a description in the step</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Load a description in the step
==============================

Call the ``createUser`` operation with Ada as the user.
```

#### 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="http-openapi-level-step">
  <title>Load a description in the step</title>
  <body>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Load a description in the step

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-openapi-level-step","detectSteps":true} */}

# Load a description in the step

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Load a description in the step

// (test {"testId":"http-openapi-level-step","detectSteps":true})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description in the step</title></head>
<body>
<!-- test {"testId":"http-openapi-level-step","detectSteps":true} -->
<h1>Load a description in the step</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Load a description in the step
==============================

.. test {"testId":"http-openapi-level-step","detectSteps":true}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-step">
  <title>Load a description in the step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-step","detectSteps":true}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Load a description in the step

Call the `createUser` operation with Ada as the user.

<!-- step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-openapi-level-step","detectSteps":false} */}

# Load a description in the step

Call the `createUser` operation with Ada as the user.

{/* step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Load a description in the step

// (test {"testId":"http-openapi-level-step","detectSteps":false})

Call the `createUser` operation with Ada as the user.

// (step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Load a description in the step</title></head>
<body>
<!-- test {"testId":"http-openapi-level-step","detectSteps":false} -->
<h1>Load a description in the step</h1>
<p>Call the <code>createUser</code> operation with Ada as the user.</p>
<!-- step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Load a description in the step
==============================

.. test {"testId":"http-openapi-level-step","detectSteps":false}

Call the ``createUser`` operation with Ada as the user.

.. step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}}

.. 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="http-openapi-level-step">
  <title>Load a description in the step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-openapi-level-step","detectSteps":false}'/>
    <p>Call the <codeph>createUser</codeph> operation with Ada as the user.</p>
    <data name="doc-detective" value='step {"httpRequest":{"openApi":{"descriptionPath":"../http-openapi/users.openapi.json","operationId":"createUser"},"request":{"body":{"name":"Ada","job":"engineer"}}}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-openapi-level-step",
      "steps": [
        {
          "httpRequest": {
            "openApi": {
              "descriptionPath": "../http-openapi/users.openapi.json",
              "operationId": "createUser"
            },
            "request": {
              "body": {
                "name": "Ada",
                "job": "engineer"
              }
            }
          }
        }
      ]
    }
  ]
}
```

#### 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: http-openapi-level-step
    steps:
      - httpRequest:
          openApi:
            descriptionPath: ../http-openapi/users.openapi.json
            operationId: createUser
          request:
            body:
              name: Ada
              job: engineer
```

## `mockRequest` permutations

`mockRequest` needs Chrome, so each example runs on headless Chrome on macOS and Linux through `runOn`. Windows is left out, as in the example above. A `runBrowserScript` step fetches the stubbed URL from the test site to show the response.

### `url` as a glob

**Varies:** `mockRequest.url` · **Value:** `"**/api/plans*"` · **Effect:** answers every URL that ends in `/api/plans`, with or without a query string.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans?page=1`. The response's plan is `pro`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans?page=1`. The response's plan is `pro`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans?page=1`. The response's plan is `pro`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans?page=1</code>. The response's plan is <code>pro</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans?page=1``. The response's plan is ``pro``.
```

#### 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="http-mock-url-glob">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans?page=1</codeph>. The response's plan is <codeph>pro</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans?page=1`. The response's plan is `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans*","response":{"body":{"plan":"pro"}}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans?page=1`. The response's plan is `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans?page=1`. The response's plan is `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans?page=1</code>. The response's plan is <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans?page=1``. The response's plan is ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-url-glob">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-url-glob","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans?page=1</codeph>. The response's plan is <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans?page=1&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans?page=1`. The response's plan is `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans*","response":{"body":{"plan":"pro"}}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans?page=1`. The response's plan is `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans?page=1`. The response's plan is `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans?page=1</code>. The response's plan is <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans?page=1``. The response's plan is ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans?page=1').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-url-glob">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-url-glob","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans*","response":{"body":{"plan":"pro"}}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans?page=1</codeph>. The response's plan is <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans?page=1&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-url-glob",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/plans*",
            "response": {
              "body": {
                "plan": "pro"
              }
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans?page=1').then((r) => r.json());",
            "output": "pro"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-url-glob
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/plans*"
          response:
            body:
              plan: pro
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans?page=1').then((r) => r.json());
          output: pro
```

### `url` as a whole URL

**Varies:** `mockRequest.url` · **Value:** `"http://localhost:8092/api/plans"` · **Effect:** answers only that exact address.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response's plan is `pro`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response's plan is `pro`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response's plan is `pro`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code>. The response's plan is <code>pro</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans``. The response's plan is ``pro``.
```

#### 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="http-mock-url-exact">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph>. The response's plan is <codeph>pro</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response's plan is `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response's plan is `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response's plan is `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response's plan is <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response's plan is ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-url-exact">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-url-exact","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response's plan is <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response's plan is `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response's plan is `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response's plan is `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response's plan is <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response's plan is ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-url-exact">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-url-exact","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"http://localhost:8092/api/plans","response":{"body":{"plan":"pro"}}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response's plan is <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-url-exact",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "http://localhost:8092/api/plans",
            "response": {
              "body": {
                "plan": "pro"
              }
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans').then((r) => r.json());",
            "output": "pro"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-url-exact
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: http://localhost:8092/api/plans
          response:
            body:
              plan: pro
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans').then((r) => r.json());
          output: pro
```

### `response.body` as an array

**Varies:** `mockRequest.response.body` · **Value:** `["pro", "team"]` · **Effect:** sends the array as JSON.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response lists `pro` and `team`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response lists `pro` and `team`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response lists `pro` and `team`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code>. The response lists <code>pro</code> and <code>team</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans``. The response lists ``pro`` and ``team``.
```

#### 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="http-mock-body-array">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph>. The response lists <codeph>pro</codeph> and <codeph>team</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response lists `pro` and `team`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"body":["pro","team"]}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response lists `pro` and `team`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response lists `pro` and `team`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response lists <code>pro</code> and <code>team</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response lists ``pro`` and ``team``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}}

.. 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="http-mock-body-array">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-body-array","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response lists <codeph>pro</codeph> and <codeph>team</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"team"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response lists `pro` and `team`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"body":["pro","team"]}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response lists `pro` and `team`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response lists `pro` and `team`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response lists <code>pro</code> and <code>team</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response lists ``pro`` and ``team``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}}

.. 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="http-mock-body-array">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-body-array","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"body":["pro","team"]}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response lists <codeph>pro</codeph> and <codeph>team</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"team"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-body-array",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/plans",
            "response": {
              "body": [
                "pro",
                "team"
              ]
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans').then((r) => r.json());",
            "output": "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: http-mock-body-array
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/plans"
          response:
            body:
              - pro
              - team
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans').then((r) => r.json());
          output: team
```

### `response.body` as a string

**Varies:** `mockRequest.response.body` · **Value:** `"pro"` · **Effect:** sends the string as is.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the text `pro`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the text `pro`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the text `pro`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code>. The response is the text <code>pro</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans``. The response is the text ``pro``.
```

#### 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="http-mock-body-string">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the text <codeph>pro</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the text `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"body":"pro"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the text `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the text `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the text <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the text ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}}

.. 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="http-mock-body-string">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-body-string","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the text <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.text());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the text `pro`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"body":"pro"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the text `pro`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the text `pro`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the text <code>pro</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the text ``pro``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.text());","output":"pro"}}

.. 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="http-mock-body-string">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-body-string","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"body":"pro"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the text <codeph>pro</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.text());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-body-string",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/plans",
            "response": {
              "body": "pro"
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans').then((r) => r.text());",
            "output": "pro"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-body-string
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/plans"
          response:
            body: pro
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans').then((r) => r.text());
          output: pro
```

### `response.bodyPath`

**Varies:** `mockRequest.response.bodyPath` · **Value:** `"plans.json"` · **Effect:** sends the file next to the test file as the body.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the list in `plans.json`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the list in `plans.json`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the list in `plans.json`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code>. The response is the list in <code>plans.json</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans``. The response is the list in ``plans.json``.
```

#### 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="http-mock-bodypath">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the list in <codeph>plans.json</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the list in `plans.json`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"bodyPath":"plans.json"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the list in `plans.json`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the list in `plans.json`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the list in <code>plans.json</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the list in ``plans.json``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-bodypath">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-bodypath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the list in <codeph>plans.json</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the list in `plans.json`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","response":{"bodyPath":"plans.json"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the list in `plans.json`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the list in `plans.json`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the list in <code>plans.json</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the list in ``plans.json``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"pro"}}

.. 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="http-mock-bodypath">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-bodypath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","response":{"bodyPath":"plans.json"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the list in <codeph>plans.json</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"pro"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-bodypath",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/plans",
            "response": {
              "bodyPath": "plans.json"
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans').then((r) => r.json());",
            "output": "pro"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-bodypath
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/plans"
          response:
            bodyPath: plans.json
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans').then((r) => r.json());
          output: pro
```

### `method`

**Varies:** `mockRequest.method` · **Value:** `"POST"` · **Effect:** answers only `POST` requests, so a `GET` to the same URL reaches the server.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub an API response

Stub the plans endpoint.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code> with <code>GET</code> and with <code>POST</code>. Only the <code>POST</code> request is stubbed.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub an API response
====================

Stub the plans endpoint.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans`` with ``GET`` and with ``POST``. Only the ``POST`` request is stubbed.
```

#### 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="http-mock-method">
  <title>Stub an API response</title>
  <body>
    <p>Stub the plans endpoint.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph> with <codeph>GET</codeph> and with <codeph>POST</codeph>. Only the <codeph>POST</codeph> request is stubbed.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

<!-- step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","method":"POST","response":{"body":"mocked-post"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

{/* step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub an API response

// (test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

// (step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code> with <code>GET</code> and with <code>POST</code>. Only the <code>POST</code> request is stubbed.</p>
<!-- step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub an API response
====================

.. test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans`` with ``GET`` and with ``POST``. Only the ``POST`` request is stubbed.

.. step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}}

.. 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="http-mock-method">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-method","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph> with <codeph>GET</codeph> and with <codeph>POST</codeph>. Only the <codeph>POST</codeph> request is stubbed.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"const u = &apos;/api/plans&apos;; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: &apos;POST&apos; }).then((r) => r.text())]).then(([get, post]) => (get === &apos;mocked-post&apos; ? &apos;GET was mocked&apos; : &apos;GET passed&apos;) + &apos;, POST &apos; + post);","output":"GET passed, POST mocked-post"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub an API response

Stub the plans endpoint.

<!-- step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

<!-- step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub an API response

Stub the plans endpoint.

{/* step {"mockRequest":{"url":"**\/api/plans","method":"POST","response":{"body":"mocked-post"}}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

{/* step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub an API response

// (test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the plans endpoint.

// (step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans` with `GET` and with `POST`. Only the `POST` request is stubbed.

// (step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub an API response</title></head>
<body>
<!-- test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub an API response</h1>
<p>Stub the plans endpoint.</p>
<!-- step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code> with <code>GET</code> and with <code>POST</code>. Only the <code>POST</code> request is stubbed.</p>
<!-- step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub an API response
====================

.. test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the plans endpoint.

.. step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans`` with ``GET`` and with ``POST``. Only the ``POST`` request is stubbed.

.. step {"runBrowserScript":{"script":"const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);","output":"GET passed, POST mocked-post"}}

.. 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="http-mock-method">
  <title>Stub an API response</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-method","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the plans endpoint.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/plans","method":"POST","response":{"body":"mocked-post"}}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph> with <codeph>GET</codeph> and with <codeph>POST</codeph>. Only the <codeph>POST</codeph> request is stubbed.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"const u = &apos;/api/plans&apos;; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: &apos;POST&apos; }).then((r) => r.text())]).then(([get, post]) => (get === &apos;mocked-post&apos; ? &apos;GET was mocked&apos; : &apos;GET passed&apos;) + &apos;, POST &apos; + post);","output":"GET passed, POST mocked-post"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-method",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/plans",
            "method": "POST",
            "response": {
              "body": "mocked-post"
            }
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);",
            "output": "GET passed, POST mocked-post"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-method
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/plans"
          method: POST
          response:
            body: mocked-post
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: "const u = '/api/plans'; return Promise.all([fetch(u).then((r) => r.text()), fetch(u, { method: 'POST' }).then((r) => r.text())]).then(([get, post]) => (get === 'mocked-post' ? 'GET was mocked' : 'GET passed') + ', POST ' + post);"
          output: GET passed, POST mocked-post
```

### `responses`

**Varies:** `mockRequest.responses` · **Value:** four responses · **Effect:** answers each request with the next response. The last response answers every later request. The responses set `statusCode`, `headers`, `bodyPath`, and `body` as a string, an array, and an object.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub a job that changes state</title></head>
<body>
<h1>Stub a job that changes state</h1>
<p>Stub the job endpoint with four responses, sent in order. The first is <code>queued</code>, with status <code>202</code> and a <code>retry-after</code> header. The others are the list of finished stages, the <code>running</code> status, and the <code>done</code> status in <code>job.json</code>.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/jobs/1</code> five times. Each request gets the next response. The fifth request gets <code>job.json</code> again, because the last response answers every later request.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Stub a job that changes state
=============================

Stub the job endpoint with four responses, sent in order. The first is ``queued``, with status ``202`` and a ``retry-after`` header. The others are the list of finished stages, the ``running`` status, and the ``done`` status in ``job.json``.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/jobs/1`` five times. Each request gets the next response. The fifth request gets ``job.json`` again, because the last response answers every later request.
```

#### 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="http-mock-responses">
  <title>Stub a job that changes state</title>
  <body>
    <p>Stub the job endpoint with four responses, sent in order. The first is <codeph>queued</codeph>, with status <codeph>202</codeph> and a <codeph>retry-after</codeph> header. The others are the list of finished stages, the <codeph>running</codeph> status, and the <codeph>done</codeph> status in <codeph>job.json</codeph>.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/jobs/1</codeph> five times. Each request gets the next response. The fifth request gets <codeph>job.json</codeph> again, because the last response answers every later request.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

<!-- step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

<!-- step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

{/* step {"mockRequest":{"url":"**\/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

{/* step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Stub a job that changes state

// (test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

// (step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

// (step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub a job that changes state</title></head>
<body>
<!-- test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub a job that changes state</h1>
<p>Stub the job endpoint with four responses, sent in order. The first is <code>queued</code>, with status <code>202</code> and a <code>retry-after</code> header. The others are the list of finished stages, the <code>running</code> status, and the <code>done</code> status in <code>job.json</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/jobs/1</code> five times. Each request gets the next response. The fifth request gets <code>job.json</code> again, because the last response answers every later request.</p>
<!-- step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Stub a job that changes state
=============================

.. test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the job endpoint with four responses, sent in order. The first is ``queued``, with status ``202`` and a ``retry-after`` header. The others are the list of finished stages, the ``running`` status, and the ``done`` status in ``job.json``.

.. step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/jobs/1`` five times. Each request gets the next response. The fifth request gets ``job.json`` again, because the last response answers every later request.

.. step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}}

.. 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="http-mock-responses">
  <title>Stub a job that changes state</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-responses","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the job endpoint with four responses, sent in order. The first is <codeph>queued</codeph>, with status <codeph>202</codeph> and a <codeph>retry-after</codeph> header. The others are the list of finished stages, the <codeph>running</codeph> status, and the <codeph>done</codeph> status in <codeph>job.json</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/jobs/1</codeph> five times. Each request gets the next response. The fifth request gets <codeph>job.json</codeph> again, because the last response answers every later request.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch(&apos;/api/jobs/1&apos;); out.push(r.status + &apos; &apos; + (r.headers.get(&apos;retry-after&apos;) || &apos;-&apos;) + &apos; &apos; + (await r.text()).trim()); } return out.join(&apos;, &apos;); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

<!-- step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

<!-- step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Stub a job that changes state

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

{/* step {"mockRequest":{"url":"**\/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

{/* step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Stub a job that changes state

// (test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Stub the job endpoint with four responses, sent in order. The first is `queued`, with status `202` and a `retry-after` header. The others are the list of finished stages, the `running` status, and the `done` status in `job.json`.

// (step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/jobs/1` five times. Each request gets the next response. The fifth request gets `job.json` again, because the last response answers every later request.

// (step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Stub a job that changes state</title></head>
<body>
<!-- test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Stub a job that changes state</h1>
<p>Stub the job endpoint with four responses, sent in order. The first is <code>queued</code>, with status <code>202</code> and a <code>retry-after</code> header. The others are the list of finished stages, the <code>running</code> status, and the <code>done</code> status in <code>job.json</code>.</p>
<!-- step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/jobs/1</code> five times. Each request gets the next response. The fifth request gets <code>job.json</code> again, because the last response answers every later request.</p>
<!-- step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Stub a job that changes state
=============================

.. test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Stub the job endpoint with four responses, sent in order. The first is ``queued``, with status ``202`` and a ``retry-after`` header. The others are the list of finished stages, the ``running`` status, and the ``done`` status in ``job.json``.

.. step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/jobs/1`` five times. Each request gets the next response. The fifth request gets ``job.json`` again, because the last response answers every later request.

.. step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}}

.. 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="http-mock-responses">
  <title>Stub a job that changes state</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-responses","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Stub the job endpoint with four responses, sent in order. The first is <codeph>queued</codeph>, with status <codeph>202</codeph> and a <codeph>retry-after</codeph> header. The others are the list of finished stages, the <codeph>running</codeph> status, and the <codeph>done</codeph> status in <codeph>job.json</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"url":"**/api/jobs/1","responses":[{"statusCode":202,"headers":{"retry-after":"1"},"body":"queued"},{"statusCode":202,"body":["build"]},{"body":{"status":"running"}},{"bodyPath":"job.json"}]}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/jobs/1</codeph> five times. Each request gets the next response. The fifth request gets <codeph>job.json</codeph> again, because the last response answers every later request.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch(&apos;/api/jobs/1&apos;); out.push(r.status + &apos; &apos; + (r.headers.get(&apos;retry-after&apos;) || &apos;-&apos;) + &apos; &apos; + (await r.text()).trim()); } return out.join(&apos;, &apos;); })();","output":"202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-responses",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "url": "**/api/jobs/1",
            "responses": [
              {
                "statusCode": 202,
                "headers": {
                  "retry-after": "1"
                },
                "body": "queued"
              },
              {
                "statusCode": 202,
                "body": [
                  "build"
                ]
              },
              {
                "body": {
                  "status": "running"
                }
              },
              {
                "bodyPath": "job.json"
              }
            ]
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();",
            "output": "202 1 queued, 202 - [\"build\"], 200 - {\"status\":\"running\"}, 200 - {\"status\":\"done\"}, 200 - {\"status\":\"done\"}"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-mock-responses
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          url: "**/api/jobs/1"
          responses:
            - statusCode: 202
              headers:
                retry-after: "1"
              body: queued
            - statusCode: 202
              body:
                - build
            - body:
                status: running
            - bodyPath: job.json
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return (async () => { const out = []; for (const _ of [1, 2, 3, 4, 5]) { const r = await fetch('/api/jobs/1'); out.push(r.status + ' ' + (r.headers.get('retry-after') || '-') + ' ' + (await r.text()).trim()); } return out.join(', '); })();
          output: 202 1 queued, 202 - ["build"], 200 - {"status":"running"}, 200 - {"status":"done"}, 200 - {"status":"done"}
```

### `harPath`

**Varies:** `mockRequest.harPath` · **Value:** `"plans.har"` · **Effect:** answers requests with the responses recorded in the HAR file next to the test file. Requests that aren't in the file reach the network.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

Open the test site at `http://localhost:8092/`.

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Replay recorded API responses</title></head>
<body>
<h1>Replay recorded API responses</h1>
<p>Answer requests with the responses recorded in <code>plans.har</code>.</p>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Fetch <code>/api/plans</code>. The response is the recorded list, <code>pro</code> and <code>team</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Replay recorded API responses
=============================

Answer requests with the responses recorded in ``plans.har``.

Open the test site at ``http://localhost:8092/``.

Fetch ``/api/plans``. The response is the recorded list, ``pro`` and ``team``.
```

#### 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="http-mock-harpath">
  <title>Replay recorded API responses</title>
  <body>
    <p>Answer requests with the responses recorded in <codeph>plans.har</codeph>.</p>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the recorded list, <codeph>pro</codeph> and <codeph>team</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

<!-- step {"mockRequest":{"harPath":"plans.har"}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

{/* step {"mockRequest":{"harPath":"plans.har"}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Replay recorded API responses

// (test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Answer requests with the responses recorded in `plans.har`.

// (step {"mockRequest":{"harPath":"plans.har"}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Replay recorded API responses</title></head>
<body>
<!-- test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Replay recorded API responses</h1>
<p>Answer requests with the responses recorded in <code>plans.har</code>.</p>
<!-- step {"mockRequest":{"harPath":"plans.har"}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the recorded list, <code>pro</code> and <code>team</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Replay recorded API responses
=============================

.. test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Answer requests with the responses recorded in ``plans.har``.

.. step {"mockRequest":{"harPath":"plans.har"}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the recorded list, ``pro`` and ``team``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}}

.. 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="http-mock-harpath">
  <title>Replay recorded API responses</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-harpath","detectSteps":true,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Answer requests with the responses recorded in <codeph>plans.har</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"harPath":"plans.har"}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the recorded list, <codeph>pro</codeph> and <codeph>team</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"team"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->

# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

<!-- step {"mockRequest":{"harPath":"plans.har"}} -->

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} */}

# Replay recorded API responses

Answer requests with the responses recorded in `plans.har`.

{/* step {"mockRequest":{"harPath":"plans.har"}} */}

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

{/* step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Replay recorded API responses

// (test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]})

Answer requests with the responses recorded in `plans.har`.

// (step {"mockRequest":{"harPath":"plans.har"}})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Fetch `/api/plans`. The response is the recorded list, `pro` and `team`.

// (step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Replay recorded API responses</title></head>
<body>
<!-- test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]} -->
<h1>Replay recorded API responses</h1>
<p>Answer requests with the responses recorded in <code>plans.har</code>.</p>
<!-- step {"mockRequest":{"harPath":"plans.har"}} -->
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Fetch <code>/api/plans</code>. The response is the recorded list, <code>pro</code> and <code>team</code>.</p>
<!-- step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Replay recorded API responses
=============================

.. test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}

Answer requests with the responses recorded in ``plans.har``.

.. step {"mockRequest":{"harPath":"plans.har"}}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Fetch ``/api/plans``. The response is the recorded list, ``pro`` and ``team``.

.. step {"runBrowserScript":{"script":"return fetch('/api/plans').then((r) => r.json());","output":"team"}}

.. 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="http-mock-harpath">
  <title>Replay recorded API responses</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-mock-harpath","detectSteps":false,"runOn":[{"platforms":["mac","linux"],"browsers":[{"name":"chrome","headless":true}]}]}'/>
    <p>Answer requests with the responses recorded in <codeph>plans.har</codeph>.</p>
    <data name="doc-detective" value='step {"mockRequest":{"harPath":"plans.har"}}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Fetch <codeph>/api/plans</codeph>. The response is the recorded list, <codeph>pro</codeph> and <codeph>team</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return fetch(&apos;/api/plans&apos;).then((r) => r.json());","output":"team"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-mock-harpath",
      "runOn": [
        {
          "platforms": [
            "mac",
            "linux"
          ],
          "browsers": [
            {
              "name": "chrome",
              "headless": true
            }
          ]
        }
      ],
      "steps": [
        {
          "mockRequest": {
            "harPath": "plans.har"
          }
        },
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return fetch('/api/plans').then((r) => r.json());",
            "output": "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: http-mock-harpath
    runOn:
      - platforms:
          - mac
          - linux
        browsers:
          - name: chrome
            headless: true
    steps:
      - mockRequest:
          harPath: plans.har
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return fetch('/api/plans').then((r) => r.json());
          output: team
```

## `runShell` permutations

### `runShell` as a string

**Varies:** `runShell` · **Value:** `"node -e \"console.log('ready')\""` · **Effect:** runs the command and passes when it exits with code `0`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command

Run this command:

[source,shell]
----
node -e "console.log('ready')"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command</title></head>
<body>
<h1>Run a command</h1>
<p>Run this command:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command
=============

Run this command:

.. code-block:: shell

   node -e "console.log('ready')"
```

#### 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="http-shell-string">
  <title>Run a command</title>
  <body>
    <p>Run this command:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-string","detectSteps":true} -->

# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```

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

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-string","detectSteps":true} */}

# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```

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

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command

// (test {"testId":"http-shell-string","detectSteps":true})

Run this command:

[source,shell]
----
node -e "console.log('ready')"
----

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

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command</title></head>
<body>
<!-- test {"testId":"http-shell-string","detectSteps":true} -->
<h1>Run a command</h1>
<p>Run this command:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":"node -e \"console.log('ready')\""} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command
=============

.. test {"testId":"http-shell-string","detectSteps":true}

Run this command:

.. code-block:: shell

   node -e "console.log('ready')"

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

.. 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="http-shell-string">
  <title>Run a command</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-string","detectSteps":true}'/>
    <p>Run this command:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;ready&apos;)\""}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-string","detectSteps":false} -->

# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```

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

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-string","detectSteps":false} */}

# Run a command

Run this command:

```shell
node -e "console.log('ready')"
```

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

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command

// (test {"testId":"http-shell-string","detectSteps":false})

Run this command:

[source,shell]
----
node -e "console.log('ready')"
----

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

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command</title></head>
<body>
<!-- test {"testId":"http-shell-string","detectSteps":false} -->
<h1>Run a command</h1>
<p>Run this command:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":"node -e \"console.log('ready')\""} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command
=============

.. test {"testId":"http-shell-string","detectSteps":false}

Run this command:

.. code-block:: shell

   node -e "console.log('ready')"

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

.. 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="http-shell-string">
  <title>Run a command</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-string","detectSteps":false}'/>
    <p>Run this command:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":"node -e \"console.log(&apos;ready&apos;)\""}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-string",
      "steps": [
        {
          "runShell": "node -e \"console.log('ready')\""
        }
      ]
    }
  ]
}
```

#### 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: http-shell-string
    steps:
      - runShell: node -e "console.log('ready')"
```

### `runShell` as an object

**Varies:** `runShell.command` · **Value:** `{"command": "node", "args": ["--version"]}` · **Effect:** runs `command` with `args`, and leaves room for options such as `stdio`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command with arguments

Print the Node.js version:

```shell
node --version
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command with arguments

Print the Node.js version:

```shell
node --version
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command with arguments

Print the Node.js version:

[source,shell]
----
node --version
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command with arguments</title></head>
<body>
<h1>Run a command with arguments</h1>
<p>Print the Node.js version:</p>
<pre><code class="language-shell">node --version</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command with arguments
============================

Print the Node.js version:

.. code-block:: shell

   node --version
```

#### 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="http-shell-object">
  <title>Run a command with arguments</title>
  <body>
    <p>Print the Node.js version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-object","detectSteps":true} -->

# Run a command with arguments

Print the Node.js version:

```shell
node --version
```

<!-- step {"runShell":{"command":"node","args":["--version"]}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-object","detectSteps":true} */}

# Run a command with arguments

Print the Node.js version:

```shell
node --version
```

{/* step {"runShell":{"command":"node","args":["--version"]}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command with arguments

// (test {"testId":"http-shell-object","detectSteps":true})

Print the Node.js version:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node","args":["--version"]}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command with arguments</title></head>
<body>
<!-- test {"testId":"http-shell-object","detectSteps":true} -->
<h1>Run a command with arguments</h1>
<p>Print the Node.js version:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node","args":["--version"]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command with arguments
============================

.. test {"testId":"http-shell-object","detectSteps":true}

Print the Node.js version:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node","args":["--version"]}}

.. 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="http-shell-object">
  <title>Run a command with arguments</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-object","detectSteps":true}'/>
    <p>Print the Node.js version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node","args":["--version"]}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-object","detectSteps":false} -->

# Run a command with arguments

Print the Node.js version:

```shell
node --version
```

<!-- step {"runShell":{"command":"node","args":["--version"]}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-object","detectSteps":false} */}

# Run a command with arguments

Print the Node.js version:

```shell
node --version
```

{/* step {"runShell":{"command":"node","args":["--version"]}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command with arguments

// (test {"testId":"http-shell-object","detectSteps":false})

Print the Node.js version:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node","args":["--version"]}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command with arguments</title></head>
<body>
<!-- test {"testId":"http-shell-object","detectSteps":false} -->
<h1>Run a command with arguments</h1>
<p>Print the Node.js version:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node","args":["--version"]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command with arguments
============================

.. test {"testId":"http-shell-object","detectSteps":false}

Print the Node.js version:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node","args":["--version"]}}

.. 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="http-shell-object">
  <title>Run a command with arguments</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-object","detectSteps":false}'/>
    <p>Print the Node.js version:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node","args":["--version"]}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-object",
      "steps": [
        {
          "runShell": {
            "command": "node",
            "args": [
              "--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: http-shell-object
    steps:
      - runShell:
          command: node
          args:
            - --version
```

### `shell: "bash"`

**Varies:** `runShell.shell` · **Value:** `bash` · **Effect:** runs the command in Bash, the default on every platform. On Windows, that's Git Bash.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command in Bash

Print a word:

```shell
echo ready
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command in Bash

Print a word:

```shell
echo ready
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command in Bash

Print a word:

[source,shell]
----
echo ready
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in Bash</title></head>
<body>
<h1>Run a command in Bash</h1>
<p>Print a word:</p>
<pre><code class="language-shell">echo ready</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command in Bash
=====================

Print a word:

.. code-block:: shell

   echo ready
```

#### 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="http-shell-shell-bash">
  <title>Run a command in Bash</title>
  <body>
    <p>Print a word:</p>
    <codeblock outputclass="language-shell">echo ready</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-shell-bash","detectSteps":true} -->

# Run a command in Bash

Print a word:

```shell
echo ready
```

<!-- step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-shell-bash","detectSteps":true} */}

# Run a command in Bash

Print a word:

```shell
echo ready
```

{/* step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command in Bash

// (test {"testId":"http-shell-shell-bash","detectSteps":true})

Print a word:

[source,shell]
----
echo ready
----

// (step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in Bash</title></head>
<body>
<!-- test {"testId":"http-shell-shell-bash","detectSteps":true} -->
<h1>Run a command in Bash</h1>
<p>Print a word:</p>
<pre><code class="language-shell">echo ready</code></pre>
<!-- step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command in Bash
=====================

.. test {"testId":"http-shell-shell-bash","detectSteps":true}

Print a word:

.. code-block:: shell

   echo ready

.. step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}}

.. 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="http-shell-shell-bash">
  <title>Run a command in Bash</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-bash","detectSteps":true}'/>
    <p>Print a word:</p>
    <codeblock outputclass="language-shell">echo ready</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-shell-bash","detectSteps":false} -->

# Run a command in Bash

Print a word:

```shell
echo ready
```

<!-- step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-shell-bash","detectSteps":false} */}

# Run a command in Bash

Print a word:

```shell
echo ready
```

{/* step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command in Bash

// (test {"testId":"http-shell-shell-bash","detectSteps":false})

Print a word:

[source,shell]
----
echo ready
----

// (step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in Bash</title></head>
<body>
<!-- test {"testId":"http-shell-shell-bash","detectSteps":false} -->
<h1>Run a command in Bash</h1>
<p>Print a word:</p>
<pre><code class="language-shell">echo ready</code></pre>
<!-- step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command in Bash
=====================

.. test {"testId":"http-shell-shell-bash","detectSteps":false}

Print a word:

.. code-block:: shell

   echo ready

.. step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}}

.. 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="http-shell-shell-bash">
  <title>Run a command in Bash</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-bash","detectSteps":false}'/>
    <p>Print a word:</p>
    <codeblock outputclass="language-shell">echo ready</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"echo ready","shell":"bash","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-shell-bash",
      "steps": [
        {
          "runShell": {
            "command": "echo ready",
            "shell": "bash",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-shell-bash
    steps:
      - runShell:
          command: echo ready
          shell: bash
          stdio: ready
```

### `shell: "cmd"`

**Varies:** `runShell.shell` · **Value:** `cmd` · **Effect:** runs the command in `cmd.exe`. It's Windows only, so `runOn` skips the test elsewhere.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command in cmd

Print the Windows version:

```shell
ver
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command in cmd

Print the Windows version:

```shell
ver
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command in cmd

Print the Windows version:

[source,shell]
----
ver
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in cmd</title></head>
<body>
<h1>Run a command in cmd</h1>
<p>Print the Windows version:</p>
<pre><code class="language-shell">ver</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command in cmd
====================

Print the Windows version:

.. code-block:: shell

   ver
```

#### 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="http-shell-shell-cmd">
  <title>Run a command in cmd</title>
  <body>
    <p>Print the Windows version:</p>
    <codeblock outputclass="language-shell">ver</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]} -->

# Run a command in cmd

Print the Windows version:

```shell
ver
```

<!-- step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]} */}

# Run a command in cmd

Print the Windows version:

```shell
ver
```

{/* step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command in cmd

// (test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]})

Print the Windows version:

[source,shell]
----
ver
----

// (step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in cmd</title></head>
<body>
<!-- test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]} -->
<h1>Run a command in cmd</h1>
<p>Print the Windows version:</p>
<pre><code class="language-shell">ver</code></pre>
<!-- step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command in cmd
====================

.. test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]}

Print the Windows version:

.. code-block:: shell

   ver

.. step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}}

.. 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="http-shell-shell-cmd">
  <title>Run a command in cmd</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-cmd","detectSteps":true,"runOn":[{"platforms":["windows"]}]}'/>
    <p>Print the Windows version:</p>
    <codeblock outputclass="language-shell">ver</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]} -->

# Run a command in cmd

Print the Windows version:

```shell
ver
```

<!-- step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]} */}

# Run a command in cmd

Print the Windows version:

```shell
ver
```

{/* step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command in cmd

// (test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]})

Print the Windows version:

[source,shell]
----
ver
----

// (step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in cmd</title></head>
<body>
<!-- test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]} -->
<h1>Run a command in cmd</h1>
<p>Print the Windows version:</p>
<pre><code class="language-shell">ver</code></pre>
<!-- step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command in cmd
====================

.. test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]}

Print the Windows version:

.. code-block:: shell

   ver

.. step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}}

.. 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="http-shell-shell-cmd">
  <title>Run a command in cmd</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-cmd","detectSteps":false,"runOn":[{"platforms":["windows"]}]}'/>
    <p>Print the Windows version:</p>
    <codeblock outputclass="language-shell">ver</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"ver","shell":"cmd","stdio":"Windows"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-shell-cmd",
      "runOn": [
        {
          "platforms": [
            "windows"
          ]
        }
      ],
      "steps": [
        {
          "runShell": {
            "command": "ver",
            "shell": "cmd",
            "stdio": "Windows"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-shell-cmd
    runOn:
      - platforms:
          - windows
    steps:
      - runShell:
          command: ver
          shell: cmd
          stdio: Windows
```

### `shell: "powershell"`

**Varies:** `runShell.shell` · **Value:** `powershell` · **Effect:** runs the command in Windows PowerShell. It's Windows only, so `runOn` skips the test elsewhere.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command in PowerShell

Print the PowerShell edition:

[source,shell]
----
echo $PSEdition
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in PowerShell</title></head>
<body>
<h1>Run a command in PowerShell</h1>
<p>Print the PowerShell edition:</p>
<pre><code class="language-shell">echo $PSEdition</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command in PowerShell
===========================

Print the PowerShell edition:

.. code-block:: shell

   echo $PSEdition
```

#### 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="http-shell-shell-powershell">
  <title>Run a command in PowerShell</title>
  <body>
    <p>Print the PowerShell edition:</p>
    <codeblock outputclass="language-shell">echo $PSEdition</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]} -->

# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```

<!-- step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]} */}

# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```

{/* step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command in PowerShell

// (test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]})

Print the PowerShell edition:

[source,shell]
----
echo $PSEdition
----

// (step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in PowerShell</title></head>
<body>
<!-- test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]} -->
<h1>Run a command in PowerShell</h1>
<p>Print the PowerShell edition:</p>
<pre><code class="language-shell">echo $PSEdition</code></pre>
<!-- step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command in PowerShell
===========================

.. test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]}

Print the PowerShell edition:

.. code-block:: shell

   echo $PSEdition

.. step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}}

.. 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="http-shell-shell-powershell">
  <title>Run a command in PowerShell</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-powershell","detectSteps":true,"runOn":[{"platforms":["windows"]}]}'/>
    <p>Print the PowerShell edition:</p>
    <codeblock outputclass="language-shell">echo $PSEdition</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]} -->

# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```

<!-- step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]} */}

# Run a command in PowerShell

Print the PowerShell edition:

```shell
echo $PSEdition
```

{/* step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command in PowerShell

// (test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]})

Print the PowerShell edition:

[source,shell]
----
echo $PSEdition
----

// (step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in PowerShell</title></head>
<body>
<!-- test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]} -->
<h1>Run a command in PowerShell</h1>
<p>Print the PowerShell edition:</p>
<pre><code class="language-shell">echo $PSEdition</code></pre>
<!-- step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command in PowerShell
===========================

.. test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]}

Print the PowerShell edition:

.. code-block:: shell

   echo $PSEdition

.. step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}}

.. 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="http-shell-shell-powershell">
  <title>Run a command in PowerShell</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-shell-powershell","detectSteps":false,"runOn":[{"platforms":["windows"]}]}'/>
    <p>Print the PowerShell edition:</p>
    <codeblock outputclass="language-shell">echo $PSEdition</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"echo $PSEdition","shell":"powershell","stdio":"Desktop"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-shell-powershell",
      "runOn": [
        {
          "platforms": [
            "windows"
          ]
        }
      ],
      "steps": [
        {
          "runShell": {
            "command": "echo $PSEdition",
            "shell": "powershell",
            "stdio": "Desktop"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-shell-powershell
    runOn:
      - platforms:
          - windows
    steps:
      - runShell:
          command: echo $PSEdition
          shell: powershell
          stdio: Desktop
```

### `exitCodes`

**Varies:** `runShell.exitCodes` · **Value:** `[1]` · **Effect:** passes only when the command exits with code `1`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Expect a failing exit code

This script exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Expect a failing exit code
==========================

This script exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"
```

#### 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="http-shell-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <p>This script exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-exitcodes","detectSteps":true} -->

# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```

<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-exitcodes","detectSteps":true} */}

# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```

{/* step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Expect a failing exit code

// (test {"testId":"http-shell-exitcodes","detectSteps":true})

This script exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----

// (step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<!-- test {"testId":"http-shell-exitcodes","detectSteps":true} -->
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Expect a failing exit code
==========================

.. test {"testId":"http-shell-exitcodes","detectSteps":true}

This script exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"

.. step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}}

.. 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="http-shell-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-exitcodes","detectSteps":true}'/>
    <p>This script exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-exitcodes","detectSteps":false} -->

# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```

<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-exitcodes","detectSteps":false} */}

# Expect a failing exit code

This script exits with code `1`:

```shell
node -e "process.exit(1)"
```

{/* step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Expect a failing exit code

// (test {"testId":"http-shell-exitcodes","detectSteps":false})

This script exits with code `1`:

[source,shell]
----
node -e "process.exit(1)"
----

// (step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<!-- test {"testId":"http-shell-exitcodes","detectSteps":false} -->
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>1</code>:</p>
<pre><code class="language-shell">node -e "process.exit(1)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Expect a failing exit code
==========================

.. test {"testId":"http-shell-exitcodes","detectSteps":false}

This script exits with code ``1``:

.. code-block:: shell

   node -e "process.exit(1)"

.. step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}}

.. 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="http-shell-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-exitcodes","detectSteps":false}'/>
    <p>This script exits with code <codeph>1</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "process.exit(1)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"process.exit(1)\"","exitCodes":[1]}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-exitcodes",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"process.exit(1)\"",
            "exitCodes": [
              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: http-shell-exitcodes
    steps:
      - runShell:
          command: node -e "process.exit(1)"
          exitCodes:
            - 1
```

### `stdio` as a string

**Varies:** `runShell.stdio` · **Value:** `"ready"` · **Effect:** passes when the output contains the text.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check command output

Run this command. It prints `ready`:

[source,shell]
----
node -e "console.log('ready')"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check command output</title></head>
<body>
<h1>Check command output</h1>
<p>Run this command. It prints <code>ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check command output
====================

Run this command. It prints ``ready``:

.. code-block:: shell

   node -e "console.log('ready')"
```

#### 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="http-shell-stdio-string">
  <title>Check command output</title>
  <body>
    <p>Run this command. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```

<!-- step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-stdio-string","detectSteps":true} */}

# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```

{/* step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check command output

// (test {"testId":"http-shell-stdio-string","detectSteps":true})

Run this command. It prints `ready`:

[source,shell]
----
node -e "console.log('ready')"
----

// (step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check command output</title></head>
<body>
<!-- test {"testId":"http-shell-stdio-string","detectSteps":true} -->
<h1>Check command output</h1>
<p>Run this command. It prints <code>ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check command output
====================

.. test {"testId":"http-shell-stdio-string","detectSteps":true}

Run this command. It prints ``ready``:

.. code-block:: shell

   node -e "console.log('ready')"

.. step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}}

.. 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="http-shell-stdio-string">
  <title>Check command output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-stdio-string","detectSteps":true}'/>
    <p>Run this command. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;ready&apos;)\"","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```

<!-- step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-stdio-string","detectSteps":false} */}

# Check command output

Run this command. It prints `ready`:

```shell
node -e "console.log('ready')"
```

{/* step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check command output

// (test {"testId":"http-shell-stdio-string","detectSteps":false})

Run this command. It prints `ready`:

[source,shell]
----
node -e "console.log('ready')"
----

// (step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check command output</title></head>
<body>
<!-- test {"testId":"http-shell-stdio-string","detectSteps":false} -->
<h1>Check command output</h1>
<p>Run this command. It prints <code>ready</code>:</p>
<pre><code class="language-shell">node -e "console.log('ready')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check command output
====================

.. test {"testId":"http-shell-stdio-string","detectSteps":false}

Run this command. It prints ``ready``:

.. code-block:: shell

   node -e "console.log('ready')"

.. step {"runShell":{"command":"node -e \"console.log('ready')\"","stdio":"ready"}}

.. 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="http-shell-stdio-string">
  <title>Check command output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-stdio-string","detectSteps":false}'/>
    <p>Run this command. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('ready')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;ready&apos;)\"","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-stdio-string",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"console.log('ready')\"",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-stdio-string
    steps:
      - runShell:
          command: node -e "console.log('ready')"
          stdio: ready
```

### `stdio` as a regular expression

**Varies:** `runShell.stdio` · **Value:** `"/^v\\d+\\./"` · **Effect:** passes when the output matches the expression between the slashes.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Match command output

Print the Node.js version. It starts with `v` and a number:

[source,shell]
----
node --version
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match command output</title></head>
<body>
<h1>Match command output</h1>
<p>Print the Node.js version. It starts with <code>v</code> and a number:</p>
<pre><code class="language-shell">node --version</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Match command output
====================

Print the Node.js version. It starts with ``v`` and a number:

.. code-block:: shell

   node --version
```

#### 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="http-shell-stdio-regex">
  <title>Match command output</title>
  <body>
    <p>Print the Node.js version. It starts with <codeph>v</codeph> and a number:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```

<!-- step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-stdio-regex","detectSteps":true} */}

# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```

{/* step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Match command output

// (test {"testId":"http-shell-stdio-regex","detectSteps":true})

Print the Node.js version. It starts with `v` and a number:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match command output</title></head>
<body>
<!-- test {"testId":"http-shell-stdio-regex","detectSteps":true} -->
<h1>Match command output</h1>
<p>Print the Node.js version. It starts with <code>v</code> and a number:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Match command output
====================

.. test {"testId":"http-shell-stdio-regex","detectSteps":true}

Print the Node.js version. It starts with ``v`` and a number:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}}

.. 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="http-shell-stdio-regex">
  <title>Match command output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-stdio-regex","detectSteps":true}'/>
    <p>Print the Node.js version. It starts with <codeph>v</codeph> and a number:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```

<!-- step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-stdio-regex","detectSteps":false} */}

# Match command output

Print the Node.js version. It starts with `v` and a number:

```shell
node --version
```

{/* step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Match command output

// (test {"testId":"http-shell-stdio-regex","detectSteps":false})

Print the Node.js version. It starts with `v` and a number:

[source,shell]
----
node --version
----

// (step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match command output</title></head>
<body>
<!-- test {"testId":"http-shell-stdio-regex","detectSteps":false} -->
<h1>Match command output</h1>
<p>Print the Node.js version. It starts with <code>v</code> and a number:</p>
<pre><code class="language-shell">node --version</code></pre>
<!-- step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Match command output
====================

.. test {"testId":"http-shell-stdio-regex","detectSteps":false}

Print the Node.js version. It starts with ``v`` and a number:

.. code-block:: shell

   node --version

.. step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}}

.. 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="http-shell-stdio-regex">
  <title>Match command output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-stdio-regex","detectSteps":false}'/>
    <p>Print the Node.js version. It starts with <codeph>v</codeph> and a number:</p>
    <codeblock outputclass="language-shell">node --version</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node --version","stdio":"/^v\\d+\\./"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-stdio-regex",
      "steps": [
        {
          "runShell": {
            "command": "node --version",
            "stdio": "/^v\\d+\\./"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-stdio-regex
    steps:
      - runShell:
          command: node --version
          stdio: /^v\d+\./
```

### `workingDirectory`

**Varies:** `runShell.workingDirectory` · **Value:** `"."` · **Effect:** runs the command in the folder that holds the test file.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a command in a folder

From the folder that holds this page, print the folder's name:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in a folder</title></head>
<body>
<h1>Run a command in a folder</h1>
<p>From the folder that holds this page, print the folder's name:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a command in a folder
=========================

From the folder that holds this page, print the folder's name:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"
```

#### 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="http-shell-workingdirectory">
  <title>Run a command in a folder</title>
  <body>
    <p>From the folder that holds this page, print the folder's name:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-workingdirectory","detectSteps":true} -->

# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-workingdirectory","detectSteps":true} */}

# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

{/* step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a command in a folder

// (test {"testId":"http-shell-workingdirectory","detectSteps":true})

From the folder that holds this page, print the folder's name:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----

// (step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in a folder</title></head>
<body>
<!-- test {"testId":"http-shell-workingdirectory","detectSteps":true} -->
<h1>Run a command in a folder</h1>
<p>From the folder that holds this page, print the folder's name:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a command in a folder
=========================

.. test {"testId":"http-shell-workingdirectory","detectSteps":true}

From the folder that holds this page, print the folder's name:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"

.. step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}}

.. 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="http-shell-workingdirectory">
  <title>Run a command in a folder</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-workingdirectory","detectSteps":true}'/>
    <p>From the folder that holds this page, print the folder's name:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(require(&apos;path&apos;).basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-workingdirectory","detectSteps":false} -->

# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-workingdirectory","detectSteps":false} */}

# Run a command in a folder

From the folder that holds this page, print the folder's name:

```shell
node -e "console.log(require('path').basename(process.cwd()))"
```

{/* step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a command in a folder

// (test {"testId":"http-shell-workingdirectory","detectSteps":false})

From the folder that holds this page, print the folder's name:

[source,shell]
----
node -e "console.log(require('path').basename(process.cwd()))"
----

// (step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a command in a folder</title></head>
<body>
<!-- test {"testId":"http-shell-workingdirectory","detectSteps":false} -->
<h1>Run a command in a folder</h1>
<p>From the folder that holds this page, print the folder's name:</p>
<pre><code class="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a command in a folder
=========================

.. test {"testId":"http-shell-workingdirectory","detectSteps":false}

From the folder that holds this page, print the folder's name:

.. code-block:: shell

   node -e "console.log(require('path').basename(process.cwd()))"

.. step {"runShell":{"command":"node -e \"console.log(require('path').basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}}

.. 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="http-shell-workingdirectory">
  <title>Run a command in a folder</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-workingdirectory","detectSteps":false}'/>
    <p>From the folder that holds this page, print the folder's name:</p>
    <codeblock outputclass="language-shell">node -e "console.log(require('path').basename(process.cwd()))"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(require(&apos;path&apos;).basename(process.cwd()))\"","workingDirectory":".","stdio":"http-shell-workingdirectory"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-workingdirectory",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"console.log(require('path').basename(process.cwd()))\"",
            "workingDirectory": ".",
            "stdio": "http-shell-workingdirectory"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-shell-workingdirectory
    steps:
      - runShell:
          command: node -e "console.log(require('path').basename(process.cwd()))"
          workingDirectory: .
          stdio: http-shell-workingdirectory
```

### `waitUntil.stdio`

**Varies:** `runShell.background.waitUntil.stdio` · **Value:** `{"stdio":"Preview ready"}` · **Effect:** starts the process in the background and returns once it's ready. Waits until the output contains the text.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Start a background process

Start the process:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Start a background process
==========================

Start the process:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

Stop it when you're done.
```

#### 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="http-shell-bg-stdio">
  <title>Start a background process</title>
  <body>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-stdio"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-bg-stdio","detectSteps":true} */}

# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-stdio"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-stdio","detectSteps":true})

Start the process:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-stdio"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-stdio","detectSteps":true} -->
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-stdio"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-stdio","detectSteps":true}

Start the process:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-stdio"}

.. 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="http-shell-bg-stdio">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-stdio","detectSteps":true}'/>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Preview ready&apos;); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-stdio"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-stdio"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-bg-stdio","detectSteps":false} */}

# Start a background process

Start the process:

```shell
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-stdio"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-stdio","detectSteps":false})

Start the process:

[source,shell]
----
node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-stdio"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-stdio","detectSteps":false} -->
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-stdio"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-stdio","detectSteps":false}

Start the process:

.. code-block:: shell

   node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-stdio"}

.. 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="http-shell-bg-stdio">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-stdio","detectSteps":false}'/>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Preview ready'); setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Preview ready&apos;); setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-stdio","waitUntil":{"stdio":"Preview ready"}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-stdio"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-bg-stdio",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"console.log('Preview ready'); setInterval(() => {}, 1000)\"",
            "background": {
              "name": "http-shell-bg-stdio",
              "waitUntil": {
                "stdio": "Preview ready"
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-shell-bg-stdio"
        }
      ]
    }
  ]
}
```

#### 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: http-shell-bg-stdio
    steps:
      - runShell:
          command: node -e "console.log('Preview ready'); setInterval(() => {}, 1000)"
          background:
            name: http-shell-bg-stdio
            waitUntil:
              stdio: Preview ready
          timeout: 15000
      - closeSurface: http-shell-bg-stdio
```

### `waitUntil.port`

**Varies:** `runShell.background.waitUntil.port` · **Value:** `{"port":8241}` · **Effect:** starts the process in the background and returns once it's ready. Waits until the port accepts connections.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Start a background process

Start a server on port 8241:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<h1>Start a background process</h1>
<p>Start a server on port 8241:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Start a background process
==========================

Start a server on port 8241:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"

Stop it when you're done.
```

#### 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="http-shell-bg-port">
  <title>Start a background process</title>
  <body>
    <p>Start a server on port 8241:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-bg-port","detectSteps":true} -->

# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-port"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-bg-port","detectSteps":true} */}

# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-port"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-port","detectSteps":true})

Start a server on port 8241:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-port"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-port","detectSteps":true} -->
<h1>Start a background process</h1>
<p>Start a server on port 8241:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-port"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-port","detectSteps":true}

Start a server on port 8241:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-port"}

.. 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="http-shell-bg-port">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-port","detectSteps":true}'/>
    <p>Start a server on port 8241:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-port"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-bg-port","detectSteps":false} -->

# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-port"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-bg-port","detectSteps":false} */}

# Start a background process

Start a server on port 8241:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-port"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-port","detectSteps":false})

Start a server on port 8241:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-port"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-port","detectSteps":false} -->
<h1>Start a background process</h1>
<p>Start a server on port 8241:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-port"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-port","detectSteps":false}

Start a server on port 8241:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-port"}

.. 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="http-shell-bg-port">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-port","detectSteps":false}'/>
    <p>Start a server on port 8241:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8241)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8241)\"","background":{"name":"http-shell-bg-port","waitUntil":{"port":8241}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-port"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-bg-port",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8241)\"",
            "background": {
              "name": "http-shell-bg-port",
              "waitUntil": {
                "port": 8241
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-shell-bg-port"
        }
      ]
    }
  ]
}
```

#### 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: http-shell-bg-port
    steps:
      - runShell:
          command: node -e "require('http').createServer((q, r) => r.end('ok')).listen(8241)"
          background:
            name: http-shell-bg-port
            waitUntil:
              port: 8241
          timeout: 15000
      - closeSurface: http-shell-bg-port
```

### `waitUntil.httpGet`

**Varies:** `runShell.background.waitUntil.httpGet` · **Value:** `{"httpGet":"http://localhost:8242/"}` · **Effect:** starts the process in the background and returns once it's ready. Waits until a `GET` request to the URL returns a `2xx` status.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Start a background process

Start a server on port 8242:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<h1>Start a background process</h1>
<p>Start a server on port 8242:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Start a background process
==========================

Start a server on port 8242:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"

Stop it when you're done.
```

#### 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="http-shell-bg-httpget">
  <title>Start a background process</title>
  <body>
    <p>Start a server on port 8242:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-bg-httpget","detectSteps":true} -->

# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-httpget"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-bg-httpget","detectSteps":true} */}

# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-httpget"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-httpget","detectSteps":true})

Start a server on port 8242:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-httpget"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-httpget","detectSteps":true} -->
<h1>Start a background process</h1>
<p>Start a server on port 8242:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-httpget"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-httpget","detectSteps":true}

Start a server on port 8242:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-httpget"}

.. 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="http-shell-bg-httpget">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-httpget","detectSteps":true}'/>
    <p>Start a server on port 8242:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-httpget"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-bg-httpget","detectSteps":false} -->

# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-httpget"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-bg-httpget","detectSteps":false} */}

# Start a background process

Start a server on port 8242:

```shell
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
```

{/* step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-httpget"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-httpget","detectSteps":false})

Start a server on port 8242:

[source,shell]
----
node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
----

// (step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-httpget"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-httpget","detectSteps":false} -->
<h1>Start a background process</h1>
<p>Start a server on port 8242:</p>
<pre><code class="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-httpget"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-httpget","detectSteps":false}

Start a server on port 8242:

.. code-block:: shell

   node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"

.. step {"runShell":{"command":"node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-httpget"}

.. 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="http-shell-bg-httpget">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-httpget","detectSteps":false}'/>
    <p>Start a server on port 8242:</p>
    <codeblock outputclass="language-shell">node -e "require('http').createServer((q, r) =&gt; r.end('ok')).listen(8242)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8242)\"","background":{"name":"http-shell-bg-httpget","waitUntil":{"httpGet":"http://localhost:8242/"}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-httpget"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-bg-httpget",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"require('http').createServer((q, r) => r.end('ok')).listen(8242)\"",
            "background": {
              "name": "http-shell-bg-httpget",
              "waitUntil": {
                "httpGet": "http://localhost:8242/"
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-shell-bg-httpget"
        }
      ]
    }
  ]
}
```

#### 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: http-shell-bg-httpget
    steps:
      - runShell:
          command: node -e "require('http').createServer((q, r) => r.end('ok')).listen(8242)"
          background:
            name: http-shell-bg-httpget
            waitUntil:
              httpGet: http://localhost:8242/
          timeout: 15000
      - closeSurface: http-shell-bg-httpget
```

### `waitUntil.delayMs`

**Varies:** `runShell.background.waitUntil.delayMs` · **Value:** `{"delayMs":500}` · **Effect:** starts the process in the background and returns once it's ready. Waits half a second.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Start a background process

Start the process:

[source,shell]
----
node -e "setInterval(() => {}, 1000)"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Start a background process
==========================

Start the process:

.. code-block:: shell

   node -e "setInterval(() => {}, 1000)"

Stop it when you're done.
```

#### 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="http-shell-bg-delayms">
  <title>Start a background process</title>
  <body>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-bg-delayms","detectSteps":true} -->

# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-delayms"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-bg-delayms","detectSteps":true} */}

# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-delayms"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-delayms","detectSteps":true})

Start the process:

[source,shell]
----
node -e "setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-delayms"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-delayms","detectSteps":true} -->
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-delayms"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-delayms","detectSteps":true}

Start the process:

.. code-block:: shell

   node -e "setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-delayms"}

.. 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="http-shell-bg-delayms">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-delayms","detectSteps":true}'/>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-delayms"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-bg-delayms","detectSteps":false} -->

# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

<!-- step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-bg-delayms"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-bg-delayms","detectSteps":false} */}

# Start a background process

Start the process:

```shell
node -e "setInterval(() => {}, 1000)"
```

{/* step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-bg-delayms"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Start a background process

// (test {"testId":"http-shell-bg-delayms","detectSteps":false})

Start the process:

[source,shell]
----
node -e "setInterval(() => {}, 1000)"
----

// (step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-bg-delayms"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a background process</title></head>
<body>
<!-- test {"testId":"http-shell-bg-delayms","detectSteps":false} -->
<h1>Start a background process</h1>
<p>Start the process:</p>
<pre><code class="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</code></pre>
<!-- step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-bg-delayms"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Start a background process
==========================

.. test {"testId":"http-shell-bg-delayms","detectSteps":false}

Start the process:

.. code-block:: shell

   node -e "setInterval(() => {}, 1000)"

.. step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-bg-delayms"}

.. 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="http-shell-bg-delayms">
  <title>Start a background process</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-bg-delayms","detectSteps":false}'/>
    <p>Start the process:</p>
    <codeblock outputclass="language-shell">node -e "setInterval(() =&gt; {}, 1000)"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"setInterval(() => {}, 1000)\"","background":{"name":"http-shell-bg-delayms","waitUntil":{"delayMs":500}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-bg-delayms"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-bg-delayms",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"setInterval(() => {}, 1000)\"",
            "background": {
              "name": "http-shell-bg-delayms",
              "waitUntil": {
                "delayMs": 500
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-shell-bg-delayms"
        }
      ]
    }
  ]
}
```

#### 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: http-shell-bg-delayms
    steps:
      - runShell:
          command: node -e "setInterval(() => {}, 1000)"
          background:
            name: http-shell-bg-delayms
            waitUntil:
              delayMs: 500
          timeout: 15000
      - closeSurface: http-shell-bg-delayms
```

### `tty: true`

**Varies:** `runShell.background.tty` · **Value:** `true` · **Effect:** runs the process in a 120-by-30 terminal instead of a pipe.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>120x30</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a process in a terminal
===========================

Print the terminal size the process sees. It's ``120x30``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

Stop it when you're done.
```

#### 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="http-shell-tty-true">
  <title>Run a process in a terminal</title>
  <body>
    <p>Print the terminal size the process sees. It's <codeph>120x30</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-tty-true","detectSteps":true} -->

# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-tty-true"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-tty-true","detectSteps":true} */}

# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-tty-true"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a process in a terminal

// (test {"testId":"http-shell-tty-true","detectSteps":true})

Print the terminal size the process sees. It's `120x30`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-tty-true"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<!-- test {"testId":"http-shell-tty-true","detectSteps":true} -->
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>120x30</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-tty-true"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a process in a terminal
===========================

.. test {"testId":"http-shell-tty-true","detectSteps":true}

Print the terminal size the process sees. It's ``120x30``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-tty-true"}

.. 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="http-shell-tty-true">
  <title>Run a process in a terminal</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-tty-true","detectSteps":true}'/>
    <p>Print the terminal size the process sees. It's <codeph>120x30</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-tty-true"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-tty-true","detectSteps":false} -->

# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-tty-true"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-tty-true","detectSteps":false} */}

# Run a process in a terminal

Print the terminal size the process sees. It's `120x30`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-tty-true"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a process in a terminal

// (test {"testId":"http-shell-tty-true","detectSteps":false})

Print the terminal size the process sees. It's `120x30`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-tty-true"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<!-- test {"testId":"http-shell-tty-true","detectSteps":false} -->
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>120x30</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-tty-true"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a process in a terminal
===========================

.. test {"testId":"http-shell-tty-true","detectSteps":false}

Print the terminal size the process sees. It's ``120x30``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-tty-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="http-shell-tty-true">
  <title>Run a process in a terminal</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-tty-true","detectSteps":false}'/>
    <p>Print the terminal size the process sees. It's <codeph>120x30</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-true","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-tty-true"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-tty-true",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"",
            "background": {
              "name": "http-shell-tty-true",
              "tty": true,
              "waitUntil": {
                "stdio": "Terminal: 120x30"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-shell-tty-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
tests:
  - testId: http-shell-tty-true
    steps:
      - runShell:
          command: "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\""
          background:
            name: http-shell-tty-true
            tty: true
            waitUntil:
              stdio: "Terminal: 120x30"
          timeout: 30000
      - closeSurface: http-shell-tty-true
```

### `tty` as an object

**Varies:** `runShell.background.tty` · **Value:** `{"cols":100,"rows":40}` · **Effect:** runs the process in a 100-by-40 terminal instead of a pipe.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>100x40</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a process in a terminal
===========================

Print the terminal size the process sees. It's ``100x40``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

Stop it when you're done.
```

#### 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="http-shell-tty-object">
  <title>Run a process in a terminal</title>
  <body>
    <p>Print the terminal size the process sees. It's <codeph>100x40</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-shell-tty-object","detectSteps":true} -->

# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-tty-object"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-shell-tty-object","detectSteps":true} */}

# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-tty-object"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a process in a terminal

// (test {"testId":"http-shell-tty-object","detectSteps":true})

Print the terminal size the process sees. It's `100x40`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-tty-object"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<!-- test {"testId":"http-shell-tty-object","detectSteps":true} -->
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>100x40</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-tty-object"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a process in a terminal
===========================

.. test {"testId":"http-shell-tty-object","detectSteps":true}

Print the terminal size the process sees. It's ``100x40``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-tty-object"}

.. 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="http-shell-tty-object">
  <title>Run a process in a terminal</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-tty-object","detectSteps":true}'/>
    <p>Print the terminal size the process sees. It's <codeph>100x40</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-tty-object"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-shell-tty-object","detectSteps":false} -->

# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-shell-tty-object"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-shell-tty-object","detectSteps":false} */}

# Run a process in a terminal

Print the terminal size the process sees. It's `100x40`:

```shell
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
```

{/* step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-shell-tty-object"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a process in a terminal

// (test {"testId":"http-shell-tty-object","detectSteps":false})

Print the terminal size the process sees. It's `100x40`:

[source,shell]
----
node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
----

// (step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-shell-tty-object"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a process in a terminal</title></head>
<body>
<!-- test {"testId":"http-shell-tty-object","detectSteps":false} -->
<h1>Run a process in a terminal</h1>
<p>Print the terminal size the process sees. It's <code>100x40</code>:</p>
<pre><code class="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-shell-tty-object"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a process in a terminal
===========================

.. test {"testId":"http-shell-tty-object","detectSteps":false}

Print the terminal size the process sees. It's ``100x40``:

.. code-block:: shell

   node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"

.. step {"runShell":{"command":"node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-shell-tty-object"}

.. 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="http-shell-tty-object">
  <title>Run a process in a terminal</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-shell-tty-object","detectSteps":false}'/>
    <p>Print the terminal size the process sees. It's <codeph>100x40</codeph>:</p>
    <codeblock outputclass="language-shell">node -e "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);\"","background":{"name":"http-shell-tty-object","tty":{"cols":100,"rows":40},"waitUntil":{"stdio":"Terminal: 100x40"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-shell-tty-object"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-shell-tty-object",
      "steps": [
        {
          "runShell": {
            "command": "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\"",
            "background": {
              "name": "http-shell-tty-object",
              "tty": {
                "cols": 100,
                "rows": 40
              },
              "waitUntil": {
                "stdio": "Terminal: 100x40"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-shell-tty-object"
        }
      ]
    }
  ]
}
```

#### 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: http-shell-tty-object
    steps:
      - runShell:
          command: "node -e \"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);\""
          background:
            name: http-shell-tty-object
            tty:
              cols: 100
              rows: 40
            waitUntil:
              stdio: "Terminal: 100x40"
          timeout: 30000
      - closeSurface: http-shell-tty-object
```

## `runCode` permutations

Default detection turns code blocks tagged `bash`, `python`, `py`, `javascript`, or `js` into unsafe `runCode` steps. Examples whose detected variants run detected steps set `allowUnsafeSteps` in their `doc-detective.json`.

### `language: "javascript"`

**Varies:** `runCode.language` · **Value:** `javascript` · **Effect:** runs the code with Node.js.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a code block

Run this code. It prints `ready`:

[source,javascript]
----
console.log("ready");
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a code block
================

Run this code. It prints ``ready``:

.. code-block:: javascript

   console.log("ready");
```

#### 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="http-code-language-javascript">
  <title>Run a code block</title>
  <body>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-language-javascript","detectSteps":true} -->

# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-language-javascript","detectSteps":true} */}

# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a code block

// (test {"testId":"http-code-language-javascript","detectSteps":true})

Run this code. It prints `ready`:

[source,javascript]
----
console.log("ready");
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-javascript","detectSteps":true} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a code block
================

.. test {"testId":"http-code-language-javascript","detectSteps":true}

Run this code. It prints ``ready``:

.. code-block:: javascript

   console.log("ready");

.. 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="http-code-language-javascript">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-javascript","detectSteps":true}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-language-javascript","detectSteps":false} -->

# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```

<!-- step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-language-javascript","detectSteps":false} */}

# Run a code block

Run this code. It prints `ready`:

```javascript
console.log("ready");
```

{/* step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a code block

// (test {"testId":"http-code-language-javascript","detectSteps":false})

Run this code. It prints `ready`:

[source,javascript]
----
console.log("ready");
----

// (step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-javascript","detectSteps":false} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<!-- step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a code block
================

.. test {"testId":"http-code-language-javascript","detectSteps":false}

Run this code. It prints ``ready``:

.. code-block:: javascript

   console.log("ready");

.. step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}}

.. 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="http-code-language-javascript">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-javascript","detectSteps":false}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"javascript","code":"console.log(\"ready\");","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-language-javascript",
      "steps": [
        {
          "runCode": {
            "language": "javascript",
            "code": "console.log(\"ready\");",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-language-javascript
    steps:
      - runCode:
          language: javascript
          code: console.log("ready");
          stdio: ready
```

### `language: "js"`

**Varies:** `runCode.language` · **Value:** `js` · **Effect:** runs the code with Node.js, like `javascript`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a code block

Run this code. It prints `ready`:

[source,js]
----
console.log("ready");
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-js">console.log("ready");</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a code block
================

Run this code. It prints ``ready``:

.. code-block:: js

   console.log("ready");
```

#### 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="http-code-language-js">
  <title>Run a code block</title>
  <body>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-js">console.log("ready");</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-language-js","detectSteps":true} -->

# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-language-js","detectSteps":true} */}

# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a code block

// (test {"testId":"http-code-language-js","detectSteps":true})

Run this code. It prints `ready`:

[source,js]
----
console.log("ready");
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-js","detectSteps":true} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-js">console.log("ready");</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a code block
================

.. test {"testId":"http-code-language-js","detectSteps":true}

Run this code. It prints ``ready``:

.. code-block:: js

   console.log("ready");

.. 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="http-code-language-js">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-js","detectSteps":true}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-js">console.log("ready");</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-language-js","detectSteps":false} -->

# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```

<!-- step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-language-js","detectSteps":false} */}

# Run a code block

Run this code. It prints `ready`:

```js
console.log("ready");
```

{/* step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a code block

// (test {"testId":"http-code-language-js","detectSteps":false})

Run this code. It prints `ready`:

[source,js]
----
console.log("ready");
----

// (step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-js","detectSteps":false} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-js">console.log("ready");</code></pre>
<!-- step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a code block
================

.. test {"testId":"http-code-language-js","detectSteps":false}

Run this code. It prints ``ready``:

.. code-block:: js

   console.log("ready");

.. step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}}

.. 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="http-code-language-js">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-js","detectSteps":false}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-js">console.log("ready");</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(\"ready\");","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-language-js",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "console.log(\"ready\");",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-language-js
    steps:
      - runCode:
          language: js
          code: console.log("ready");
          stdio: ready
```

### `language: "python"`

**Varies:** `runCode.language` · **Value:** `python` · **Effect:** runs the code with Python.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a code block

Run this code. It prints `ready`:

[source,python]
----
print("ready")
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-python">print("ready")</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a code block
================

Run this code. It prints ``ready``:

.. code-block:: python

   print("ready")
```

#### 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="http-code-language-python">
  <title>Run a code block</title>
  <body>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-python">print("ready")</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-language-python","detectSteps":true} -->

# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-language-python","detectSteps":true} */}

# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a code block

// (test {"testId":"http-code-language-python","detectSteps":true})

Run this code. It prints `ready`:

[source,python]
----
print("ready")
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-python","detectSteps":true} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-python">print("ready")</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a code block
================

.. test {"testId":"http-code-language-python","detectSteps":true}

Run this code. It prints ``ready``:

.. code-block:: python

   print("ready")

.. 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="http-code-language-python">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-python","detectSteps":true}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-python">print("ready")</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-language-python","detectSteps":false} -->

# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```

<!-- step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-language-python","detectSteps":false} */}

# Run a code block

Run this code. It prints `ready`:

```python
print("ready")
```

{/* step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a code block

// (test {"testId":"http-code-language-python","detectSteps":false})

Run this code. It prints `ready`:

[source,python]
----
print("ready")
----

// (step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-python","detectSteps":false} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-python">print("ready")</code></pre>
<!-- step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a code block
================

.. test {"testId":"http-code-language-python","detectSteps":false}

Run this code. It prints ``ready``:

.. code-block:: python

   print("ready")

.. step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}}

.. 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="http-code-language-python">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-python","detectSteps":false}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-python">print("ready")</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"python","code":"print(\"ready\")","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-language-python",
      "steps": [
        {
          "runCode": {
            "language": "python",
            "code": "print(\"ready\")",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-language-python
    steps:
      - runCode:
          language: python
          code: print("ready")
          stdio: ready
```

### `language: "py"`

**Varies:** `runCode.language` · **Value:** `py` · **Effect:** runs the code with Python, like `python`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a code block

Run this code. It prints `ready`:

[source,py]
----
print("ready")
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-py">print("ready")</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a code block
================

Run this code. It prints ``ready``:

.. code-block:: py

   print("ready")
```

#### 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="http-code-language-py">
  <title>Run a code block</title>
  <body>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-py">print("ready")</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-language-py","detectSteps":true} -->

# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-language-py","detectSteps":true} */}

# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a code block

// (test {"testId":"http-code-language-py","detectSteps":true})

Run this code. It prints `ready`:

[source,py]
----
print("ready")
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-py","detectSteps":true} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-py">print("ready")</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a code block
================

.. test {"testId":"http-code-language-py","detectSteps":true}

Run this code. It prints ``ready``:

.. code-block:: py

   print("ready")

.. 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="http-code-language-py">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-py","detectSteps":true}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-py">print("ready")</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-language-py","detectSteps":false} -->

# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```

<!-- step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-language-py","detectSteps":false} */}

# Run a code block

Run this code. It prints `ready`:

```py
print("ready")
```

{/* step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a code block

// (test {"testId":"http-code-language-py","detectSteps":false})

Run this code. It prints `ready`:

[source,py]
----
print("ready")
----

// (step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-py","detectSteps":false} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-py">print("ready")</code></pre>
<!-- step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a code block
================

.. test {"testId":"http-code-language-py","detectSteps":false}

Run this code. It prints ``ready``:

.. code-block:: py

   print("ready")

.. step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}}

.. 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="http-code-language-py">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-py","detectSteps":false}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-py">print("ready")</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"py","code":"print(\"ready\")","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-language-py",
      "steps": [
        {
          "runCode": {
            "language": "py",
            "code": "print(\"ready\")",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-language-py
    steps:
      - runCode:
          language: py
          code: print("ready")
          stdio: ready
```

### `language: "bash"`

**Varies:** `runCode.language` · **Value:** `bash` · **Effect:** runs the code with Bash.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a code block

Run this code. It prints `ready`:

[source,bash]
----
echo "ready"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a code block
================

Run this code. It prints ``ready``:

.. code-block:: bash

   echo "ready"
```

#### 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="http-code-language-bash">
  <title>Run a code block</title>
  <body>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-language-bash","detectSteps":true} -->

# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-language-bash","detectSteps":true} */}

# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a code block

// (test {"testId":"http-code-language-bash","detectSteps":true})

Run this code. It prints `ready`:

[source,bash]
----
echo "ready"
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-bash","detectSteps":true} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a code block
================

.. test {"testId":"http-code-language-bash","detectSteps":true}

Run this code. It prints ``ready``:

.. code-block:: bash

   echo "ready"

.. 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="http-code-language-bash">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-bash","detectSteps":true}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-language-bash","detectSteps":false} -->

# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```

<!-- step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-language-bash","detectSteps":false} */}

# Run a code block

Run this code. It prints `ready`:

```bash
echo "ready"
```

{/* step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a code block

// (test {"testId":"http-code-language-bash","detectSteps":false})

Run this code. It prints `ready`:

[source,bash]
----
echo "ready"
----

// (step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a code block</title></head>
<body>
<!-- test {"testId":"http-code-language-bash","detectSteps":false} -->
<h1>Run a code block</h1>
<p>Run this code. It prints <code>ready</code>:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
<!-- step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a code block
================

.. test {"testId":"http-code-language-bash","detectSteps":false}

Run this code. It prints ``ready``:

.. code-block:: bash

   echo "ready"

.. step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}}

.. 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="http-code-language-bash">
  <title>Run a code block</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-language-bash","detectSteps":false}'/>
    <p>Run this code. It prints <codeph>ready</codeph>:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-language-bash",
      "steps": [
        {
          "runCode": {
            "language": "bash",
            "code": "echo \"ready\"",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-language-bash
    steps:
      - runCode:
          language: bash
          code: echo "ready"
          stdio: ready
```

### `exitCodes`

**Varies:** `runCode.exitCodes` · **Value:** `[2]` · **Effect:** passes only when the code exits with code `2`. The block is marked `testIgnore`, because a detected step expects code `0`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Expect a failing exit code

This script exits with code `2`:

```js
process.exit(2);
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Expect a failing exit code

This script exits with code `2`:

```js
process.exit(2);
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Expect a failing exit code

This script exits with code `2`:

[source,js]
----
process.exit(2);
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>2</code>:</p>
<pre><code class="language-js">process.exit(2);</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Expect a failing exit code
==========================

This script exits with code ``2``:

.. code-block:: js

   process.exit(2);
```

#### 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="http-code-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <p>This script exits with code <codeph>2</codeph>:</p>
    <codeblock outputclass="language-js">process.exit(2);</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-exitcodes","detectSteps":true} -->

# Expect a failing exit code

This script exits with code `2`:

```js testIgnore
process.exit(2);
```

<!-- step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-exitcodes","detectSteps":true} */}

# Expect a failing exit code

This script exits with code `2`:

```js testIgnore
process.exit(2);
```

{/* step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Expect a failing exit code

// (test {"testId":"http-code-exitcodes","detectSteps":true})

This script exits with code `2`:

[source,js,testIgnore]
----
process.exit(2);
----

// (step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<!-- test {"testId":"http-code-exitcodes","detectSteps":true} -->
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>2</code>:</p>
<!-- test ignore start -->
<pre><code class="language-js">process.exit(2);</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Expect a failing exit code
==========================

.. test {"testId":"http-code-exitcodes","detectSteps":true}

This script exits with code ``2``:

.. code-block:: js
   :class: testIgnore

   process.exit(2);

.. step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}}

.. 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="http-code-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-exitcodes","detectSteps":true}'/>
    <p>This script exits with code <codeph>2</codeph>:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">process.exit(2);</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-exitcodes","detectSteps":false} -->

# Expect a failing exit code

This script exits with code `2`:

```js
process.exit(2);
```

<!-- step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-exitcodes","detectSteps":false} */}

# Expect a failing exit code

This script exits with code `2`:

```js
process.exit(2);
```

{/* step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Expect a failing exit code

// (test {"testId":"http-code-exitcodes","detectSteps":false})

This script exits with code `2`:

[source,js]
----
process.exit(2);
----

// (step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Expect a failing exit code</title></head>
<body>
<!-- test {"testId":"http-code-exitcodes","detectSteps":false} -->
<h1>Expect a failing exit code</h1>
<p>This script exits with code <code>2</code>:</p>
<pre><code class="language-js">process.exit(2);</code></pre>
<!-- step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Expect a failing exit code
==========================

.. test {"testId":"http-code-exitcodes","detectSteps":false}

This script exits with code ``2``:

.. code-block:: js

   process.exit(2);

.. step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}}

.. 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="http-code-exitcodes">
  <title>Expect a failing exit code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-exitcodes","detectSteps":false}'/>
    <p>This script exits with code <codeph>2</codeph>:</p>
    <codeblock outputclass="language-js">process.exit(2);</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"process.exit(2);","exitCodes":[2]}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-exitcodes",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "process.exit(2);",
            "exitCodes": [
              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: http-code-exitcodes
    steps:
      - runCode:
          language: js
          code: process.exit(2);
          exitCodes:
            - 2
```

### `stdio` as a regular expression

**Varies:** `runCode.stdio` · **Value:** `"/^\\d+$/"` · **Effect:** passes when the output matches the expression between the slashes.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Match code output

This script prints a number:

```js
console.log(6 * 7);
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Match code output

This script prints a number:

```js
console.log(6 * 7);
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Match code output

This script prints a number:

[source,js]
----
console.log(6 * 7);
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match code output</title></head>
<body>
<h1>Match code output</h1>
<p>This script prints a number:</p>
<pre><code class="language-js">console.log(6 * 7);</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Match code output
=================

This script prints a number:

.. code-block:: js

   console.log(6 * 7);
```

#### 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="http-code-stdio-regex">
  <title>Match code output</title>
  <body>
    <p>This script prints a number:</p>
    <codeblock outputclass="language-js">console.log(6 * 7);</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

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

# Match code output

This script prints a number:

```js testIgnore
console.log(6 * 7);
```

<!-- step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-stdio-regex","detectSteps":true} */}

# Match code output

This script prints a number:

```js testIgnore
console.log(6 * 7);
```

{/* step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Match code output

// (test {"testId":"http-code-stdio-regex","detectSteps":true})

This script prints a number:

[source,js,testIgnore]
----
console.log(6 * 7);
----

// (step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match code output</title></head>
<body>
<!-- test {"testId":"http-code-stdio-regex","detectSteps":true} -->
<h1>Match code output</h1>
<p>This script prints a number:</p>
<!-- test ignore start -->
<pre><code class="language-js">console.log(6 * 7);</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Match code output
=================

.. test {"testId":"http-code-stdio-regex","detectSteps":true}

This script prints a number:

.. code-block:: js
   :class: testIgnore

   console.log(6 * 7);

.. step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}}

.. 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="http-code-stdio-regex">
  <title>Match code output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-stdio-regex","detectSteps":true}'/>
    <p>This script prints a number:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">console.log(6 * 7);</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

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

# Match code output

This script prints a number:

```js
console.log(6 * 7);
```

<!-- step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-stdio-regex","detectSteps":false} */}

# Match code output

This script prints a number:

```js
console.log(6 * 7);
```

{/* step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Match code output

// (test {"testId":"http-code-stdio-regex","detectSteps":false})

This script prints a number:

[source,js]
----
console.log(6 * 7);
----

// (step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Match code output</title></head>
<body>
<!-- test {"testId":"http-code-stdio-regex","detectSteps":false} -->
<h1>Match code output</h1>
<p>This script prints a number:</p>
<pre><code class="language-js">console.log(6 * 7);</code></pre>
<!-- step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Match code output
=================

.. test {"testId":"http-code-stdio-regex","detectSteps":false}

This script prints a number:

.. code-block:: js

   console.log(6 * 7);

.. step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}}

.. 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="http-code-stdio-regex">
  <title>Match code output</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-stdio-regex","detectSteps":false}'/>
    <p>This script prints a number:</p>
    <codeblock outputclass="language-js">console.log(6 * 7);</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(6 * 7);","stdio":"/^\\d+$/"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-stdio-regex",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "console.log(6 * 7);",
            "stdio": "/^\\d+$/"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-stdio-regex
    steps:
      - runCode:
          language: js
          code: console.log(6 * 7);
          stdio: /^\d+$/
```

### `background`

**Varies:** `runCode.background` · **Value:** `{"name": "http-code-server", "waitUntil": {"port": 8251}}` · **Effect:** starts the code as a background process and returns once its port accepts connections. The block is marked `testIgnore`, because the server never exits.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Start a server from code

Start a server on port 8251:

```js
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Start a server from code

Start a server on port 8251:

```js
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Start a server from code

Start a server on port 8251:

[source,js]
----
require('http').createServer((q, r) => r.end('ok')).listen(8251);
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a server from code</title></head>
<body>
<h1>Start a server from code</h1>
<p>Start a server on port 8251:</p>
<pre><code class="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Start a server from code
========================

Start a server on port 8251:

.. code-block:: js

   require('http').createServer((q, r) => r.end('ok')).listen(8251);

Stop it when you're done.
```

#### 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="http-code-background">
  <title>Start a server from code</title>
  <body>
    <p>Start a server on port 8251:</p>
    <codeblock outputclass="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-background","detectSteps":true} -->

# Start a server from code

Start a server on port 8251:

```js testIgnore
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

<!-- step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-code-server"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-background","detectSteps":true} */}

# Start a server from code

Start a server on port 8251:

```js testIgnore
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

{/* step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-code-server"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Start a server from code

// (test {"testId":"http-code-background","detectSteps":true})

Start a server on port 8251:

[source,js,testIgnore]
----
require('http').createServer((q, r) => r.end('ok')).listen(8251);
----

// (step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-code-server"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a server from code</title></head>
<body>
<!-- test {"testId":"http-code-background","detectSteps":true} -->
<h1>Start a server from code</h1>
<p>Start a server on port 8251:</p>
<!-- test ignore start -->
<pre><code class="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-code-server"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Start a server from code
========================

.. test {"testId":"http-code-background","detectSteps":true}

Start a server on port 8251:

.. code-block:: js
   :class: testIgnore

   require('http').createServer((q, r) => r.end('ok')).listen(8251);

.. step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-code-server"}

.. 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="http-code-background">
  <title>Start a server from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-background","detectSteps":true}'/>
    <p>Start a server on port 8251:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-code-server"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-background","detectSteps":false} -->

# Start a server from code

Start a server on port 8251:

```js
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

<!-- step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-code-server"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-background","detectSteps":false} */}

# Start a server from code

Start a server on port 8251:

```js
require('http').createServer((q, r) => r.end('ok')).listen(8251);
```

{/* step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-code-server"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Start a server from code

// (test {"testId":"http-code-background","detectSteps":false})

Start a server on port 8251:

[source,js]
----
require('http').createServer((q, r) => r.end('ok')).listen(8251);
----

// (step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}})

Stop it when you're done.

// (step {"closeSurface":"http-code-server"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Start a server from code</title></head>
<body>
<!-- test {"testId":"http-code-background","detectSteps":false} -->
<h1>Start a server from code</h1>
<p>Start a server on port 8251:</p>
<pre><code class="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</code></pre>
<!-- step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-code-server"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Start a server from code
========================

.. test {"testId":"http-code-background","detectSteps":false}

Start a server on port 8251:

.. code-block:: js

   require('http').createServer((q, r) => r.end('ok')).listen(8251);

.. step {"runCode":{"language":"js","code":"require('http').createServer((q, r) => r.end('ok')).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}}

Stop it when you're done.

.. step {"closeSurface":"http-code-server"}

.. 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="http-code-background">
  <title>Start a server from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-background","detectSteps":false}'/>
    <p>Start a server on port 8251:</p>
    <codeblock outputclass="language-js">require('http').createServer((q, r) =&gt; r.end('ok')).listen(8251);</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"require(&apos;http&apos;).createServer((q, r) => r.end(&apos;ok&apos;)).listen(8251);","background":{"name":"http-code-server","waitUntil":{"port":8251}},"timeout":15000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-code-server"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-background",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "require('http').createServer((q, r) => r.end('ok')).listen(8251);",
            "background": {
              "name": "http-code-server",
              "waitUntil": {
                "port": 8251
              }
            },
            "timeout": 15000
          }
        },
        {
          "closeSurface": "http-code-server"
        }
      ]
    }
  ]
}
```

#### 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: http-code-background
    steps:
      - runCode:
          language: js
          code: require('http').createServer((q, r) => r.end('ok')).listen(8251);
          background:
            name: http-code-server
            waitUntil:
              port: 8251
          timeout: 15000
      - closeSurface: http-code-server
```

### `background.tty: true` with `language: "js"`

**Varies:** `runCode.background.tty` · **Value:** `true` · **Effect:** runs the JavaScript with Node.js in a 120-by-30 terminal instead of a pipe. The block is marked `testIgnore`, because the code never exits.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Check the terminal size from code

Print the size of the terminal the code runs in:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

Stop it when you're done.
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Check the terminal size from code

Print the size of the terminal the code runs in:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

Stop it when you're done.
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Check the terminal size from code

Print the size of the terminal the code runs in:

[source,js]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

Stop it when you're done.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the terminal size from code</title></head>
<body>
<h1>Check the terminal size from code</h1>
<p>Print the size of the terminal the code runs in:</p>
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<p>Stop it when you're done.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Check the terminal size from code
=================================

Print the size of the terminal the code runs in:

.. code-block:: js

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

Stop it when you're done.
```

#### 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="http-code-tty-js">
  <title>Check the terminal size from code</title>
  <body>
    <p>Print the size of the terminal the code runs in:</p>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <p>Stop it when you're done.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-tty-js","detectSteps":true} -->

# Check the terminal size from code

Print the size of the terminal the code runs in:

```js testIgnore
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-code-tty-js"} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-tty-js","detectSteps":true} */}

# Check the terminal size from code

Print the size of the terminal the code runs in:

```js testIgnore
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

{/* step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-code-tty-js"} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Check the terminal size from code

// (test {"testId":"http-code-tty-js","detectSteps":true})

Print the size of the terminal the code runs in:

[source,js,testIgnore]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

// (step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-code-tty-js"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the terminal size from code</title></head>
<body>
<!-- test {"testId":"http-code-tty-js","detectSteps":true} -->
<h1>Check the terminal size from code</h1>
<p>Print the size of the terminal the code runs in:</p>
<!-- test ignore start -->
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-code-tty-js"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Check the terminal size from code
=================================

.. test {"testId":"http-code-tty-js","detectSteps":true}

Print the size of the terminal the code runs in:

.. code-block:: js
   :class: testIgnore

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

.. step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-code-tty-js"}

.. 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="http-code-tty-js">
  <title>Check the terminal size from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-tty-js","detectSteps":true}'/>
    <p>Print the size of the terminal the code runs in:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-code-tty-js"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-tty-js","detectSteps":false} -->

# Check the terminal size from code

Print the size of the terminal the code runs in:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->

Stop it when you're done.

<!-- step {"closeSurface":"http-code-tty-js"} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-tty-js","detectSteps":false} */}

# Check the terminal size from code

Print the size of the terminal the code runs in:

```js
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
```

{/* step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} */}

Stop it when you're done.

{/* step {"closeSurface":"http-code-tty-js"} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Check the terminal size from code

// (test {"testId":"http-code-tty-js","detectSteps":false})

Print the size of the terminal the code runs in:

[source,js]
----
console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);
----

// (step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}})

Stop it when you're done.

// (step {"closeSurface":"http-code-tty-js"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Check the terminal size from code</title></head>
<body>
<!-- test {"testId":"http-code-tty-js","detectSteps":false} -->
<h1>Check the terminal size from code</h1>
<p>Print the size of the terminal the code runs in:</p>
<pre><code class="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</code></pre>
<!-- step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}} -->
<p>Stop it when you're done.</p>
<!-- step {"closeSurface":"http-code-tty-js"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Check the terminal size from code
=================================

.. test {"testId":"http-code-tty-js","detectSteps":false}

Print the size of the terminal the code runs in:

.. code-block:: js

   console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);

.. step {"runCode":{"language":"js","code":"console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}

Stop it when you're done.

.. step {"closeSurface":"http-code-tty-js"}

.. 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="http-code-tty-js">
  <title>Check the terminal size from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-tty-js","detectSteps":false}'/>
    <p>Print the size of the terminal the code runs in:</p>
    <codeblock outputclass="language-js">console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() =&gt; {}, 1000);</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Terminal: &apos; + process.stdout.columns + &apos;x&apos; + process.stdout.rows); setInterval(() => {}, 1000);","background":{"name":"http-code-tty-js","tty":true,"waitUntil":{"stdio":"Terminal: 120x30"}},"timeout":30000}}'/>
    <p>Stop it when you're done.</p>
    <data name="doc-detective" value='step {"closeSurface":"http-code-tty-js"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-tty-js",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);",
            "background": {
              "name": "http-code-tty-js",
              "tty": true,
              "waitUntil": {
                "stdio": "Terminal: 120x30"
              }
            },
            "timeout": 30000
          }
        },
        {
          "closeSurface": "http-code-tty-js"
        }
      ]
    }
  ]
}
```

#### 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: http-code-tty-js
    steps:
      - runCode:
          language: js
          code: "console.log('Terminal: ' + process.stdout.columns + 'x' + process.stdout.rows); setInterval(() => {}, 1000);"
          background:
            name: http-code-tty-js
            tty: true
            waitUntil:
              stdio: "Terminal: 120x30"
          timeout: 30000
      - closeSurface: http-code-tty-js
```

### `directory` with `path`

**Varies:** `runCode.directory` · **Value:** `"output"` · **Effect:** saves the output to `greeting.txt` in the `output` folder next to the test file, and creates the folder if it doesn't exist. The block is marked `testIgnore`, because a detected step has no `path`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js
console.log('Hello from the output folder');
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js
console.log('Hello from the output folder');
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

[source,js]
----
console.log('Hello from the output folder');
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a greeting from code</title></head>
<body>
<h1>Save a greeting from code</h1>
<p>Print a greeting with Node.js, and save the output to <code>greeting.txt</code> in the <code>output</code> folder:</p>
<pre><code class="language-js">console.log('Hello from the output folder');</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Save a greeting from code
=========================

Print a greeting with Node.js, and save the output to ``greeting.txt`` in the ``output`` folder:

.. code-block:: js

   console.log('Hello from the output folder');
```

#### 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="http-code-directory">
  <title>Save a greeting from code</title>
  <body>
    <p>Print a greeting with Node.js, and save the output to <filepath>greeting.txt</filepath> in the <filepath>output</filepath> folder:</p>
    <codeblock outputclass="language-js">console.log('Hello from the output folder');</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-directory","detectSteps":true} -->

# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js testIgnore
console.log('Hello from the output folder');
```

<!-- step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-directory","detectSteps":true} */}

# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js testIgnore
console.log('Hello from the output folder');
```

{/* step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Save a greeting from code

// (test {"testId":"http-code-directory","detectSteps":true})

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

[source,js,testIgnore]
----
console.log('Hello from the output folder');
----

// (step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a greeting from code</title></head>
<body>
<!-- test {"testId":"http-code-directory","detectSteps":true} -->
<h1>Save a greeting from code</h1>
<p>Print a greeting with Node.js, and save the output to <code>greeting.txt</code> in the <code>output</code> folder:</p>
<!-- test ignore start -->
<pre><code class="language-js">console.log('Hello from the output folder');</code></pre>
<!-- test ignore end -->
<!-- step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Save a greeting from code
=========================

.. test {"testId":"http-code-directory","detectSteps":true}

Print a greeting with Node.js, and save the output to ``greeting.txt`` in the ``output`` folder:

.. code-block:: js
   :class: testIgnore

   console.log('Hello from the output folder');

.. step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}}

.. 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="http-code-directory">
  <title>Save a greeting from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-directory","detectSteps":true}'/>
    <p>Print a greeting with Node.js, and save the output to <filepath>greeting.txt</filepath> in the <filepath>output</filepath> folder:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-js">console.log('Hello from the output folder');</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Hello from the output folder&apos;);","path":"greeting.txt","directory":"output"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-directory","detectSteps":false} -->

# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js
console.log('Hello from the output folder');
```

<!-- step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-directory","detectSteps":false} */}

# Save a greeting from code

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

```js
console.log('Hello from the output folder');
```

{/* step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Save a greeting from code

// (test {"testId":"http-code-directory","detectSteps":false})

Print a greeting with Node.js, and save the output to `greeting.txt` in the `output` folder:

[source,js]
----
console.log('Hello from the output folder');
----

// (step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Save a greeting from code</title></head>
<body>
<!-- test {"testId":"http-code-directory","detectSteps":false} -->
<h1>Save a greeting from code</h1>
<p>Print a greeting with Node.js, and save the output to <code>greeting.txt</code> in the <code>output</code> folder:</p>
<pre><code class="language-js">console.log('Hello from the output folder');</code></pre>
<!-- step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Save a greeting from code
=========================

.. test {"testId":"http-code-directory","detectSteps":false}

Print a greeting with Node.js, and save the output to ``greeting.txt`` in the ``output`` folder:

.. code-block:: js

   console.log('Hello from the output folder');

.. step {"runCode":{"language":"js","code":"console.log('Hello from the output folder');","path":"greeting.txt","directory":"output"}}

.. 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="http-code-directory">
  <title>Save a greeting from code</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-directory","detectSteps":false}'/>
    <p>Print a greeting with Node.js, and save the output to <filepath>greeting.txt</filepath> in the <filepath>output</filepath> folder:</p>
    <codeblock outputclass="language-js">console.log('Hello from the output folder');</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"js","code":"console.log(&apos;Hello from the output folder&apos;);","path":"greeting.txt","directory":"output"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-directory",
      "steps": [
        {
          "runCode": {
            "language": "js",
            "code": "console.log('Hello from the output folder');",
            "path": "greeting.txt",
            "directory": "output"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-directory
    steps:
      - runCode:
          language: js
          code: console.log('Hello from the output folder');
          path: greeting.txt
          directory: output
```

### `testIgnore` on a code block

**Varies:** `codeBlock.meta` · **Value:** `testIgnore` · **Effect:** detection skips the marked block and runs the other one. HTML and DITA wrap the block in `test ignore` statements instead.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Show code without running it

Run this code:

```bash
echo "ready"
```

To install the tool for every project on your machine, run:

```bash
npm install --global ./greeter
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Show code without running it

Run this code:

```bash
echo "ready"
```

To install the tool for every project on your machine, run:

```bash
npm install --global ./greeter
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Show code without running it

Run this code:

[source,bash]
----
echo "ready"
----

To install the tool for every project on your machine, run:

[source,bash]
----
npm install --global ./greeter
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show code without running it</title></head>
<body>
<h1>Show code without running it</h1>
<p>Run this code:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
<p>To install the tool for every project on your machine, run:</p>
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Show code without running it
============================

Run this code:

.. code-block:: bash

   echo "ready"

To install the tool for every project on your machine, run:

.. code-block:: bash

   npm install --global ./greeter
```

#### 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="http-code-testignore">
  <title>Show code without running it</title>
  <body>
    <p>Run this code:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
    <p>To install the tool for every project on your machine, run:</p>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-testignore","detectSteps":true} -->

# Show code without running it

Run this code:

```bash
echo "ready"
```

To install the tool for every project on your machine, run:

```bash testIgnore
npm install --global ./greeter
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-testignore","detectSteps":true} */}

# Show code without running it

Run this code:

```bash
echo "ready"
```

To install the tool for every project on your machine, run:

```bash testIgnore
npm install --global ./greeter
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Show code without running it

// (test {"testId":"http-code-testignore","detectSteps":true})

Run this code:

[source,bash]
----
echo "ready"
----

To install the tool for every project on your machine, run:

[source,bash,testIgnore]
----
npm install --global ./greeter
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show code without running it</title></head>
<body>
<!-- test {"testId":"http-code-testignore","detectSteps":true} -->
<h1>Show code without running it</h1>
<p>Run this code:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
<p>To install the tool for every project on your machine, run:</p>
<!-- test ignore start -->
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
<!-- test ignore end -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Show code without running it
============================

.. test {"testId":"http-code-testignore","detectSteps":true}

Run this code:

.. code-block:: bash

   echo "ready"

To install the tool for every project on your machine, run:

.. code-block:: bash
   :class: testIgnore

   npm install --global ./greeter

.. 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="http-code-testignore">
  <title>Show code without running it</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-testignore","detectSteps":true}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
    <p>To install the tool for every project on your machine, run:</p>
    <data name="doc-detective" value="test ignore start"/>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
    <data name="doc-detective" value="test ignore end"/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-testignore","detectSteps":false} -->

# Show code without running it

Run this code:

```bash
echo "ready"
```

<!-- step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} -->

To install the tool for every project on your machine, run:

```bash
npm install --global ./greeter
```

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-testignore","detectSteps":false} */}

# Show code without running it

Run this code:

```bash
echo "ready"
```

{/* step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} */}

To install the tool for every project on your machine, run:

```bash
npm install --global ./greeter
```

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Show code without running it

// (test {"testId":"http-code-testignore","detectSteps":false})

Run this code:

[source,bash]
----
echo "ready"
----

// (step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}})

To install the tool for every project on your machine, run:

[source,bash]
----
npm install --global ./greeter
----

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Show code without running it</title></head>
<body>
<!-- test {"testId":"http-code-testignore","detectSteps":false} -->
<h1>Show code without running it</h1>
<p>Run this code:</p>
<pre><code class="language-bash">echo "ready"</code></pre>
<!-- step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}} -->
<p>To install the tool for every project on your machine, run:</p>
<pre><code class="language-bash">npm install --global ./greeter</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Show code without running it
============================

.. test {"testId":"http-code-testignore","detectSteps":false}

Run this code:

.. code-block:: bash

   echo "ready"

.. step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}}

To install the tool for every project on your machine, run:

.. code-block:: bash

   npm install --global ./greeter

.. 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="http-code-testignore">
  <title>Show code without running it</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-testignore","detectSteps":false}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-bash">echo "ready"</codeblock>
    <data name="doc-detective" value='step {"runCode":{"language":"bash","code":"echo \"ready\"","stdio":"ready"}}'/>
    <p>To install the tool for every project on your machine, run:</p>
    <codeblock outputclass="language-bash">npm install --global ./greeter</codeblock>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-testignore",
      "steps": [
        {
          "runCode": {
            "language": "bash",
            "code": "echo \"ready\"",
            "stdio": "ready"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-testignore
    steps:
      - runCode:
          language: bash
          code: echo "ready"
          stdio: ready
```

### `allowUnsafeSteps: true`

**Varies:** `config.allowUnsafeSteps` · **Value:** `true` · **Effect:** runs steps marked `unsafe`, including every detected `runCode` step.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run an unsafe step

Run this code:

[source,javascript]
----
console.log("ready");
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run an unsafe step</title></head>
<body>
<h1>Run an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run an unsafe step
==================

Run this code:

.. code-block:: javascript

   console.log("ready");
```

#### 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="http-code-unsafe-allowed">
  <title>Run an unsafe step</title>
  <body>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-unsafe-allowed","detectSteps":true} -->

# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-unsafe-allowed","detectSteps":true} */}

# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run an unsafe step

// (test {"testId":"http-code-unsafe-allowed","detectSteps":true})

Run this code:

[source,javascript]
----
console.log("ready");
----

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run an unsafe step</title></head>
<body>
<!-- test {"testId":"http-code-unsafe-allowed","detectSteps":true} -->
<h1>Run an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run an unsafe step
==================

.. test {"testId":"http-code-unsafe-allowed","detectSteps":true}

Run this code:

.. code-block:: javascript

   console.log("ready");

.. 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="http-code-unsafe-allowed">
  <title>Run an unsafe step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-unsafe-allowed","detectSteps":true}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-unsafe-allowed","detectSteps":false} -->

# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```

<!-- step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-unsafe-allowed","detectSteps":false} */}

# Run an unsafe step

Run this code:

```javascript
console.log("ready");
```

{/* step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run an unsafe step

// (test {"testId":"http-code-unsafe-allowed","detectSteps":false})

Run this code:

[source,javascript]
----
console.log("ready");
----

// (step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run an unsafe step</title></head>
<body>
<!-- test {"testId":"http-code-unsafe-allowed","detectSteps":false} -->
<h1>Run an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<!-- step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run an unsafe step
==================

.. test {"testId":"http-code-unsafe-allowed","detectSteps":false}

Run this code:

.. code-block:: javascript

   console.log("ready");

.. step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}}

.. 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="http-code-unsafe-allowed">
  <title>Run an unsafe step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-unsafe-allowed","detectSteps":false}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <data name="doc-detective" value='step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-unsafe-allowed",
      "steps": [
        {
          "unsafe": true,
          "runCode": {
            "language": "javascript",
            "code": "console.log(\"ready\");"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-unsafe-allowed
    steps:
      - unsafe: true
        runCode:
          language: javascript
          code: console.log("ready");
```

### `allowUnsafeSteps: false`

**Varies:** `config.allowUnsafeSteps` · **Value:** `false` · **Effect:** skips steps marked `unsafe`, and the test runs its other steps. A test whose steps are all skipped reports `SKIPPED`.

#### Prose

#### Markdown

**`prose.md`**

````markdown title="prose.md"
# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```
````

#### MDX

**`prose.mdx`**

````mdx title="prose.mdx"
# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```
````

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Skip an unsafe step

Run this code:

[source,javascript]
----
console.log("ready");
----

Then confirm that Node.js runs:

[source,shell]
----
node -e "console.log('done')"
----
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Skip an unsafe step</title></head>
<body>
<h1>Skip an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<p>Then confirm that Node.js runs:</p>
<pre><code class="language-shell">node -e "console.log('done')"</code></pre>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Skip an unsafe step
===================

Run this code:

.. code-block:: javascript

   console.log("ready");

Then confirm that Node.js runs:

.. code-block:: shell

   node -e "console.log('done')"
```

#### 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="http-code-unsafe-blocked">
  <title>Skip an unsafe step</title>
  <body>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <p>Then confirm that Node.js runs:</p>
    <codeblock outputclass="language-shell">node -e "console.log('done')"</codeblock>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

````markdown title="detected.md"
<!-- test {"testId":"http-code-unsafe-blocked","detectSteps":true} -->

# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```

<!-- step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} -->

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

#### MDX

**`detected.mdx`**

````mdx title="detected.mdx"
{/* test {"testId":"http-code-unsafe-blocked","detectSteps":true} */}

# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```

{/* step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} */}

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

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Skip an unsafe step

// (test {"testId":"http-code-unsafe-blocked","detectSteps":true})

Run this code:

[source,javascript]
----
console.log("ready");
----

Then confirm that Node.js runs:

[source,shell]
----
node -e "console.log('done')"
----

// (step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Skip an unsafe step</title></head>
<body>
<!-- test {"testId":"http-code-unsafe-blocked","detectSteps":true} -->
<h1>Skip an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<p>Then confirm that Node.js runs:</p>
<pre><code class="language-shell">node -e "console.log('done')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Skip an unsafe step
===================

.. test {"testId":"http-code-unsafe-blocked","detectSteps":true}

Run this code:

.. code-block:: javascript

   console.log("ready");

Then confirm that Node.js runs:

.. code-block:: shell

   node -e "console.log('done')"

.. step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}}

.. 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="http-code-unsafe-blocked">
  <title>Skip an unsafe step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-unsafe-blocked","detectSteps":true}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <p>Then confirm that Node.js runs:</p>
    <codeblock outputclass="language-shell">node -e "console.log('done')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;done&apos;)\"","stdio":"done"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

````markdown title="inline.md"
<!-- test {"testId":"http-code-unsafe-blocked","detectSteps":false} -->

# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

<!-- step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} -->

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```

<!-- step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} -->

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

#### MDX

**`inline.mdx`**

````mdx title="inline.mdx"
{/* test {"testId":"http-code-unsafe-blocked","detectSteps":false} */}

# Skip an unsafe step

Run this code:

```javascript
console.log("ready");
```

{/* step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} */}

Then confirm that Node.js runs:

```shell
node -e "console.log('done')"
```

{/* step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} */}

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

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Skip an unsafe step

// (test {"testId":"http-code-unsafe-blocked","detectSteps":false})

Run this code:

[source,javascript]
----
console.log("ready");
----

// (step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}})

Then confirm that Node.js runs:

[source,shell]
----
node -e "console.log('done')"
----

// (step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Skip an unsafe step</title></head>
<body>
<!-- test {"testId":"http-code-unsafe-blocked","detectSteps":false} -->
<h1>Skip an unsafe step</h1>
<p>Run this code:</p>
<pre><code class="language-javascript">console.log("ready");</code></pre>
<!-- step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}} -->
<p>Then confirm that Node.js runs:</p>
<pre><code class="language-shell">node -e "console.log('done')"</code></pre>
<!-- step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Skip an unsafe step
===================

.. test {"testId":"http-code-unsafe-blocked","detectSteps":false}

Run this code:

.. code-block:: javascript

   console.log("ready");

.. step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}}

Then confirm that Node.js runs:

.. code-block:: shell

   node -e "console.log('done')"

.. step {"runShell":{"command":"node -e \"console.log('done')\"","stdio":"done"}}

.. 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="http-code-unsafe-blocked">
  <title>Skip an unsafe step</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-code-unsafe-blocked","detectSteps":false}'/>
    <p>Run this code:</p>
    <codeblock outputclass="language-javascript">console.log("ready");</codeblock>
    <data name="doc-detective" value='step {"unsafe":true,"runCode":{"language":"javascript","code":"console.log(\"ready\");"}}'/>
    <p>Then confirm that Node.js runs:</p>
    <codeblock outputclass="language-shell">node -e "console.log('done')"</codeblock>
    <data name="doc-detective" value='step {"runShell":{"command":"node -e \"console.log(&apos;done&apos;)\"","stdio":"done"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-code-unsafe-blocked",
      "steps": [
        {
          "unsafe": true,
          "runCode": {
            "language": "javascript",
            "code": "console.log(\"ready\");"
          }
        },
        {
          "runShell": {
            "command": "node -e \"console.log('done')\"",
            "stdio": "done"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-code-unsafe-blocked
    steps:
      - unsafe: true
        runCode:
          language: javascript
          code: console.log("ready");
      - runShell:
          command: node -e "console.log('done')"
          stdio: done
```

## `runBrowserScript` permutations

### `runBrowserScript` as a string

**Varies:** `runBrowserScript` · **Value:** `"return document.title;"` · **Effect:** runs the script in the page and passes unless it throws.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Evaluate <code>document.title</code> in the console.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a script in the page
========================

Open the test site at ``http://localhost:8092/``.

Evaluate ``document.title`` in the console.
```

#### 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="http-script-string">
  <title>Run a script in the page</title>
  <body>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Evaluate <codeph>document.title</codeph> in the console.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-script-string","detectSteps":true} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `document.title` in the console.

<!-- step {"runBrowserScript":"return document.title;"} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-script-string","detectSteps":true} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `document.title` in the console.

{/* step {"runBrowserScript":"return document.title;"} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a script in the page

// (test {"testId":"http-script-string","detectSteps":true})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `document.title` in the console.

// (step {"runBrowserScript":"return document.title;"})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-string","detectSteps":true} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>document.title</code> in the console.</p>
<!-- step {"runBrowserScript":"return document.title;"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a script in the page
========================

.. test {"testId":"http-script-string","detectSteps":true}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``document.title`` in the console.

.. step {"runBrowserScript":"return document.title;"}

.. 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="http-script-string">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-string","detectSteps":true}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>document.title</codeph> in the console.</p>
    <data name="doc-detective" value='step {"runBrowserScript":"return document.title;"}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-script-string","detectSteps":false} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `document.title` in the console.

<!-- step {"runBrowserScript":"return document.title;"} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-script-string","detectSteps":false} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `document.title` in the console.

{/* step {"runBrowserScript":"return document.title;"} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a script in the page

// (test {"testId":"http-script-string","detectSteps":false})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `document.title` in the console.

// (step {"runBrowserScript":"return document.title;"})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-string","detectSteps":false} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>document.title</code> in the console.</p>
<!-- step {"runBrowserScript":"return document.title;"} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a script in the page
========================

.. test {"testId":"http-script-string","detectSteps":false}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``document.title`` in the console.

.. step {"runBrowserScript":"return document.title;"}

.. 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="http-script-string">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-string","detectSteps":false}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>document.title</codeph> in the console.</p>
    <data name="doc-detective" value='step {"runBrowserScript":"return document.title;"}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-script-string",
      "steps": [
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": "return document.title;"
        }
      ]
    }
  ]
}
```

#### 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: http-script-string
    steps:
      - goTo: http://localhost:8092/
      - runBrowserScript: return document.title;
```

### `output` as a string

**Varies:** `runBrowserScript.output` · **Value:** `"Basic HTML Elements Demo"` · **Effect:** passes when the script's return value contains the text.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Evaluate <code>document.title</code> in the console. The title is <code>Basic HTML Elements Demo</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a script in the page
========================

Open the test site at ``http://localhost:8092/``.

Evaluate ``document.title`` in the console. The title is ``Basic HTML Elements Demo``.
```

#### 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="http-script-output-string">
  <title>Run a script in the page</title>
  <body>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Evaluate <codeph>document.title</codeph> in the console. The title is <codeph>Basic HTML Elements Demo</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-script-output-string","detectSteps":true} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

<!-- step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-script-output-string","detectSteps":true} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

{/* step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a script in the page

// (test {"testId":"http-script-output-string","detectSteps":true})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

// (step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-output-string","detectSteps":true} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>document.title</code> in the console. The title is <code>Basic HTML Elements Demo</code>.</p>
<!-- step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a script in the page
========================

.. test {"testId":"http-script-output-string","detectSteps":true}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``document.title`` in the console. The title is ``Basic HTML Elements Demo``.

.. step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}}

.. 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="http-script-output-string">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-output-string","detectSteps":true}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>document.title</codeph> in the console. The title is <codeph>Basic HTML Elements Demo</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-script-output-string","detectSteps":false} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

<!-- step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-script-output-string","detectSteps":false} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

{/* step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a script in the page

// (test {"testId":"http-script-output-string","detectSteps":false})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `document.title` in the console. The title is `Basic HTML Elements Demo`.

// (step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-output-string","detectSteps":false} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>document.title</code> in the console. The title is <code>Basic HTML Elements Demo</code>.</p>
<!-- step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a script in the page
========================

.. test {"testId":"http-script-output-string","detectSteps":false}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``document.title`` in the console. The title is ``Basic HTML Elements Demo``.

.. step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}}

.. 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="http-script-output-string">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-output-string","detectSteps":false}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>document.title</codeph> in the console. The title is <codeph>Basic HTML Elements Demo</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return document.title;","output":"Basic HTML Elements Demo"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-script-output-string",
      "steps": [
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return document.title;",
            "output": "Basic HTML Elements Demo"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-script-output-string
    steps:
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return document.title;
          output: Basic HTML Elements Demo
```

### `output` as a regular expression

**Varies:** `runBrowserScript.output` · **Value:** `"/^http:\\/\\/localhost:8092/"` · **Effect:** passes when the return value matches the expression between the slashes.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `window.location.href` in the console. It starts with the test site's address.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `window.location.href` in the console. It starts with the test site's address.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a script in the page

Open the test site at `http://localhost:8092/`.

Evaluate `window.location.href` in the console. It starts with the test site's address.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Evaluate <code>window.location.href</code> in the console. It starts with the test site's address.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a script in the page
========================

Open the test site at ``http://localhost:8092/``.

Evaluate ``window.location.href`` in the console. It starts with the test site's address.
```

#### 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="http-script-output-regex">
  <title>Run a script in the page</title>
  <body>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Evaluate <codeph>window.location.href</codeph> in the console. It starts with the test site's address.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-script-output-regex","detectSteps":true} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `window.location.href` in the console. It starts with the test site's address.

<!-- step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-script-output-regex","detectSteps":true} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `window.location.href` in the console. It starts with the test site's address.

{/* step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a script in the page

// (test {"testId":"http-script-output-regex","detectSteps":true})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `window.location.href` in the console. It starts with the test site's address.

// (step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-output-regex","detectSteps":true} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>window.location.href</code> in the console. It starts with the test site's address.</p>
<!-- step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a script in the page
========================

.. test {"testId":"http-script-output-regex","detectSteps":true}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``window.location.href`` in the console. It starts with the test site's address.

.. step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}}

.. 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="http-script-output-regex">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-output-regex","detectSteps":true}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>window.location.href</codeph> in the console. It starts with the test site's address.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-script-output-regex","detectSteps":false} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Evaluate `window.location.href` in the console. It starts with the test site's address.

<!-- step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-script-output-regex","detectSteps":false} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Evaluate `window.location.href` in the console. It starts with the test site's address.

{/* step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a script in the page

// (test {"testId":"http-script-output-regex","detectSteps":false})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Evaluate `window.location.href` in the console. It starts with the test site's address.

// (step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-output-regex","detectSteps":false} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Evaluate <code>window.location.href</code> in the console. It starts with the test site's address.</p>
<!-- step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a script in the page
========================

.. test {"testId":"http-script-output-regex","detectSteps":false}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Evaluate ``window.location.href`` in the console. It starts with the test site's address.

.. step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}}

.. 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="http-script-output-regex">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-output-regex","detectSteps":false}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Evaluate <codeph>window.location.href</codeph> in the console. It starts with the test site's address.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return window.location.href;","output":"/^http:\\/\\/localhost:8092/"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-script-output-regex",
      "steps": [
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return window.location.href;",
            "output": "/^http:\\/\\/localhost:8092/"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-script-output-regex
    steps:
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return window.location.href;
          output: /^http:\/\/localhost:8092/
```

### `args`

**Varies:** `runBrowserScript.args` · **Value:** `["foo", "bar"]` · **Effect:** passes each value to the script, which reads it from `arguments`.

#### Prose

#### Markdown

**`prose.md`**

```markdown title="prose.md"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Join `foo` and `bar` in the console. The result is `foobar`.
```

#### MDX

**`prose.mdx`**

```mdx title="prose.mdx"
# Run a script in the page

Open the test site at `http://localhost:8092/`.

Join `foo` and `bar` in the console. The result is `foobar`.
```

#### AsciiDoc

**`prose.adoc`**

```asciidoc title="prose.adoc"
= Run a script in the page

Open the test site at `http://localhost:8092/`.

Join `foo` and `bar` in the console. The result is `foobar`.
```

#### HTML

**`prose.html`**

```html title="prose.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<p>Join <code>foo</code> and <code>bar</code> in the console. The result is <code>foobar</code>.</p>
</body>
</html>
```

#### reStructuredText

**`prose.rst`**

```rst title="prose.rst"
Run a script in the page
========================

Open the test site at ``http://localhost:8092/``.

Join ``foo`` and ``bar`` in the console. The result is ``foobar``.
```

#### 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="http-script-args">
  <title>Run a script in the page</title>
  <body>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <p>Join <codeph>foo</codeph> and <codeph>bar</codeph> in the console. The result is <codeph>foobar</codeph>.</p>
  </body>
</topic>
```

#### Detected

#### Markdown

**`detected.md`**

```markdown title="detected.md"
<!-- test {"testId":"http-script-args","detectSteps":true} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Join `foo` and `bar` in the console. The result is `foobar`.

<!-- step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} -->

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

#### MDX

**`detected.mdx`**

```mdx title="detected.mdx"
{/* test {"testId":"http-script-args","detectSteps":true} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Join `foo` and `bar` in the console. The result is `foobar`.

{/* step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} */}

{/* test end */}
```

#### AsciiDoc

**`detected.adoc`**

```asciidoc title="detected.adoc"
= Run a script in the page

// (test {"testId":"http-script-args","detectSteps":true})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Join `foo` and `bar` in the console. The result is `foobar`.

// (step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}})

// (test end)
```

#### HTML

**`detected.html`**

```html title="detected.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-args","detectSteps":true} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Join <code>foo</code> and <code>bar</code> in the console. The result is <code>foobar</code>.</p>
<!-- step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`detected.rst`**

```rst title="detected.rst"
Run a script in the page
========================

.. test {"testId":"http-script-args","detectSteps":true}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Join ``foo`` and ``bar`` in the console. The result is ``foobar``.

.. step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}}

.. 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="http-script-args">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-args","detectSteps":true}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Join <codeph>foo</codeph> and <codeph>bar</codeph> in the console. The result is <codeph>foobar</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}}'/>
    <data name="doc-detective" value="test end"/>
  </body>
</topic>
```

#### Inline

#### Markdown

**`inline.md`**

```markdown title="inline.md"
<!-- test {"testId":"http-script-args","detectSteps":false} -->

# Run a script in the page

Open the test site at `http://localhost:8092/`.

<!-- step {"goTo":"http://localhost:8092/"} -->

Join `foo` and `bar` in the console. The result is `foobar`.

<!-- step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} -->

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

#### MDX

**`inline.mdx`**

```mdx title="inline.mdx"
{/* test {"testId":"http-script-args","detectSteps":false} */}

# Run a script in the page

Open the test site at `http://localhost:8092/`.

{/* step {"goTo":"http://localhost:8092/"} */}

Join `foo` and `bar` in the console. The result is `foobar`.

{/* step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} */}

{/* test end */}
```

#### AsciiDoc

**`inline.adoc`**

```asciidoc title="inline.adoc"
= Run a script in the page

// (test {"testId":"http-script-args","detectSteps":false})

Open the test site at `http://localhost:8092/`.

// (step {"goTo":"http://localhost:8092/"})

Join `foo` and `bar` in the console. The result is `foobar`.

// (step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}})

// (test end)
```

#### HTML

**`inline.html`**

```html title="inline.html"
<!DOCTYPE html>
<html lang="en">
<head><title>Run a script in the page</title></head>
<body>
<!-- test {"testId":"http-script-args","detectSteps":false} -->
<h1>Run a script in the page</h1>
<p>Open the test site at <code>http://localhost:8092/</code>.</p>
<!-- step {"goTo":"http://localhost:8092/"} -->
<p>Join <code>foo</code> and <code>bar</code> in the console. The result is <code>foobar</code>.</p>
<!-- step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}} -->
<!-- test end -->
</body>
</html>
```

#### reStructuredText

**`inline.rst`**

```rst title="inline.rst"
Run a script in the page
========================

.. test {"testId":"http-script-args","detectSteps":false}

Open the test site at ``http://localhost:8092/``.

.. step {"goTo":"http://localhost:8092/"}

Join ``foo`` and ``bar`` in the console. The result is ``foobar``.

.. step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}}

.. 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="http-script-args">
  <title>Run a script in the page</title>
  <body>
    <data name="doc-detective" value='test {"testId":"http-script-args","detectSteps":false}'/>
    <p>Open the test site at <codeph>http://localhost:8092/</codeph>.</p>
    <data name="doc-detective" value='step {"goTo":"http://localhost:8092/"}'/>
    <p>Join <codeph>foo</codeph> and <codeph>bar</codeph> in the console. The result is <codeph>foobar</codeph>.</p>
    <data name="doc-detective" value='step {"runBrowserScript":{"script":"return arguments[0] + arguments[1];","args":["foo","bar"],"output":"foobar"}}'/>
    <data name="doc-detective" value="test end"/>
  </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",
  "tests": [
    {
      "testId": "http-script-args",
      "steps": [
        {
          "goTo": "http://localhost:8092/"
        },
        {
          "runBrowserScript": {
            "script": "return arguments[0] + arguments[1];",
            "args": [
              "foo",
              "bar"
            ],
            "output": "foobar"
          }
        }
      ]
    }
  ]
}
```

#### 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: http-script-args
    steps:
      - goTo: http://localhost:8092/
      - runBrowserScript:
          script: return arguments[0] + arguments[1];
          args:
            - foo
            - bar
          output: foobar
```