Skip to content

Commit 3340e45

Browse files
committed
Set up testing for Doc Detective install page
1 parent 8599016 commit 3340e45

File tree

7 files changed

+84
-90
lines changed

7 files changed

+84
-90
lines changed

.doc-detective.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
{
2-
"input": ".",
3-
"defaultCommand": "runTests",
4-
"relativePathBase": "file",
5-
"runTests": {
6-
"input": ["./docs", "./blog"],
7-
"recursive": true,
8-
"detectSteps": true
9-
},
10-
"fileTypes": [
11-
{
12-
"name": "Markdown/MDX",
13-
"extensions": [".md", ".mdx"],
14-
"testStartStatementOpen": "<!-- test-start",
15-
"testStartStatementClose": "-->",
16-
"testIgnoreStatement": "<!-- test-ignore -->",
17-
"testEndStatement": "<!-- test-end -->",
18-
"stepStatementOpen": "<!-- step-start",
19-
"stepStatementClose": "-->",
20-
"markup": [
21-
{
22-
"name": "External hyperlink/image",
23-
"regex": ["\\[.*?]\\(([^/].*?)\\)"],
24-
"actions": ["checkLink"]
25-
}
26-
]
27-
}
28-
]
2+
"$schema": "https://raw.githubusercontent.com/doc-detective/common/refs/heads/main/dist/schemas/config_v3.schema.json",
3+
"input": ["docs/get-started/installation/index.mdx"],
4+
"allowUnsafeSteps": true,
5+
"fileTypes": ["markdown"]
296
}

docs/get-started/installation.md

Lines changed: 0 additions & 60 deletions
This file was deleted.
17.4 KB
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
sidebar_label: Installation
3+
---
4+
5+
import spec from "./sample.spec.json";
6+
import CodeBlock from '@theme/CodeBlock';
7+
8+
# Installation
9+
10+
Downloading and running Doc Detective is straightforward. Follow these steps to install Doc Detective and run your first test:
11+
12+
1. Install prerequisites:
13+
14+
- [Node.js](https://nodejs.org/) v18 or later
15+
16+
2. In a terminal, install Doc Detective globally:
17+
18+
<CodeBlock language="bash" title="Install Doc Detective">
19+
npm i -g doc-detective
20+
</CodeBlock>
21+
{/* step runShell: "npm i -g doc-detective" */}
22+
23+
:::note
24+
25+
If you're working in a local copy of the `doc-detective` repository, you need to run `npm i` to install local dependencies.
26+
27+
:::
28+
29+
3. Save this file to your current directory as _sample.spec.json_:
30+
31+
<CodeBlock language="json" title="sample.spec.json">
32+
{JSON.stringify(spec, null, 2)}
33+
</CodeBlock>
34+
35+
4. Run a test, pointing to the file you just created:
36+
37+
<CodeBlock language="bash" title="Run test">
38+
npx doc-detective --input sample.spec.json
39+
</CodeBlock>
40+
{/* step runShell:
41+
command: "npx doc-detective --input sample.spec.json"
42+
workingDirectory: "." */}
43+
44+
45+
Congratulations! You've run your first test with Doc Detective. :tada:
46+
47+
You should see output in the terminal indicating the progress and results of the test. Results are also saved in a `testResults-<timestamp>.json` file in the current directory (configurable with the `--output` option), and this test saves a screenshot to example.png:
48+
49+
[![Sample test screenshot](./example.png)](./example.png)
50+
51+
## Next steps
52+
53+
Next up, take a look at some of the [concepts](/docs/get-started/concepts) native to Doc Detective, check out some of the guided [tutorials](/docs/category/tutorials), or explore how to write [tests](/docs/get-started/tests) and [actions](/docs/category/actions) to automate your documentation testing.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"tests": [
3+
{
4+
"steps": [
5+
{
6+
"description": "Go to the specified URL",
7+
"goTo": "https://example.com"
8+
},
9+
{
10+
"description": "Verify the presence of the main heading",
11+
"find": "Example Domain"
12+
},
13+
{
14+
"description": "Verify that the 'Learn more' link is present and working",
15+
"click": "Learn more"
16+
},
17+
{
18+
"description": "Capture a screenshot of the resulting page",
19+
"screenshot": "example.png"
20+
}
21+
]
22+
}
23+
]
24+
}

docs/get-started/intro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npx doc-detective
1313

1414
Want to use the Docker image? [Check it out](https://github.com/doc-detective/docker-image).
1515

16-
See the [Installation](/docs/get-started/installation.md) guide to get started. Come chat on [Discord](https://discord.gg/uAfSjVH7yr)!
16+
See the [Installation](/docs/get-started/installation) guide to get started. Come chat on [Discord](https://discord.gg/uAfSjVH7yr)!
1717

1818
## What's Doc Detective?
1919

@@ -62,4 +62,4 @@ As an open source and accessible project, Doc Detective is for anyone who's inte
6262

6363
## Next steps
6464

65-
Want to take Doc Detective for a spin? [Get started](/docs/get-started/installation.md).
65+
Want to take Doc Detective for a spin? [Get started](/docs/get-started/installation).

sidebars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const sidebars: SidebarsConfig = {
1818
label: "Get started",
1919
items: [
2020
"get-started/intro",
21-
"get-started/installation",
21+
"get-started/installation/index",
2222
"get-started/concepts",
2323
"get-started/create-your-first-test",
2424
"get-started/sample-tests",

0 commit comments

Comments
 (0)