doc-detective 2.13.0-dev.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +14 -14
- package/.github/dependabot.yml +11 -11
- package/.github/workflows/docker-image.yml +19 -19
- package/.github/workflows/electron-publish.yml +17 -17
- package/.github/workflows/npm-publish.yml +67 -67
- package/.github/workflows/npm-test.yaml +49 -49
- package/CONTRIBUTIONS.md +27 -27
- package/LICENSE +20 -20
- package/README.md +126 -126
- package/dev/dev.spec.json +62 -62
- package/dev/index.js +5 -5
- package/doc-detective.svg +26 -0
- package/package.json +44 -43
- package/samples/.doc-detective.json +82 -90
- package/samples/{doc-content.md → doc-content-detect.md} +10 -8
- package/samples/doc-content-inline-tests.md +28 -28
- package/samples/docker-hello.spec.json +14 -0
- package/samples/http.spec.json +26 -0
- package/samples/kitten-search-inline.md +15 -0
- package/samples/kitten-search.spec.json +28 -0
- package/samples/tests.spec.json +70 -70
- package/samples/variables.env +4 -4
- package/src/index.js +84 -84
- package/src/utils.js +190 -188
- package/test/artifacts/cleanup.spec.json +18 -18
- package/test/artifacts/config.json +42 -42
- package/test/artifacts/doc-content.md +17 -17
- package/test/artifacts/env +2 -2
- package/test/artifacts/httpRequest.spec.json +55 -55
- package/test/artifacts/runShell.spec.json +29 -29
- package/test/artifacts/setup.spec.json +18 -18
- package/test/artifacts/test.spec.json +60 -60
- package/test/runCoverage.test.js +24 -18
- package/test/runTests.test.js +29 -22
- package/test/test-config.json +12 -12
- package/test/test-results.json +124 -124
- package/test/utils.test.js +210 -204
- package/.doc-detective.json +0 -63
package/test/utils.test.js
CHANGED
|
@@ -1,204 +1,210 @@
|
|
|
1
|
-
const { setArgs, setConfig, outputResults } = require("../src/utils");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
args: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"--
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
".",
|
|
47
|
-
"--
|
|
48
|
-
"
|
|
49
|
-
"--
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
".",
|
|
67
|
-
"--
|
|
68
|
-
"
|
|
69
|
-
"--
|
|
70
|
-
"
|
|
71
|
-
"--
|
|
72
|
-
"
|
|
73
|
-
"--
|
|
74
|
-
"
|
|
75
|
-
"--
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"--
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// Output results
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
fs.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
1
|
+
const { setArgs, setConfig, outputResults } = require("../src/utils");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
before(async function () {
|
|
6
|
+
const { expect } = await import("chai");
|
|
7
|
+
global.expect = expect;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe("Util tests", function () {
|
|
11
|
+
// Test that arguments are parsed correctly
|
|
12
|
+
it("Yargs parses arguments correctly", function () {
|
|
13
|
+
const argSets = [
|
|
14
|
+
{
|
|
15
|
+
args: ["node", "runTests.js", "--input", "input.spec.json"],
|
|
16
|
+
expected: { i: "input.spec.json" },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
args: [
|
|
20
|
+
"node",
|
|
21
|
+
"runTests.js",
|
|
22
|
+
"--input",
|
|
23
|
+
"input.spec.json",
|
|
24
|
+
"--logLevel",
|
|
25
|
+
"debug",
|
|
26
|
+
],
|
|
27
|
+
expected: { i: "input.spec.json", l: "debug" },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
args: [
|
|
31
|
+
"node",
|
|
32
|
+
"runTests.js",
|
|
33
|
+
"--input",
|
|
34
|
+
"input.spec.json",
|
|
35
|
+
"--logLevel",
|
|
36
|
+
"debug",
|
|
37
|
+
"--config",
|
|
38
|
+
"config.json",
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
expected: { i: "input.spec.json", l: "debug", c: "config.json" },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
args: [
|
|
45
|
+
"node",
|
|
46
|
+
"runTests.js",
|
|
47
|
+
"--input",
|
|
48
|
+
"input.spec.json",
|
|
49
|
+
"--output",
|
|
50
|
+
".",
|
|
51
|
+
"--logLevel",
|
|
52
|
+
"debug",
|
|
53
|
+
"--config",
|
|
54
|
+
"config.json",
|
|
55
|
+
],
|
|
56
|
+
expected: {
|
|
57
|
+
i: "input.spec.json",
|
|
58
|
+
o: ".",
|
|
59
|
+
l: "debug",
|
|
60
|
+
c: "config.json",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
args: [
|
|
65
|
+
"node",
|
|
66
|
+
"runTests.js",
|
|
67
|
+
"--input",
|
|
68
|
+
"input.spec.json",
|
|
69
|
+
"--output",
|
|
70
|
+
".",
|
|
71
|
+
"--logLevel",
|
|
72
|
+
"debug",
|
|
73
|
+
"--config",
|
|
74
|
+
"config.json",
|
|
75
|
+
"--recursive",
|
|
76
|
+
"false",
|
|
77
|
+
"--setup",
|
|
78
|
+
"setup.spec.json",
|
|
79
|
+
"--cleanup",
|
|
80
|
+
"cleanup.spec.json",
|
|
81
|
+
],
|
|
82
|
+
expected: {
|
|
83
|
+
i: "input.spec.json",
|
|
84
|
+
o: ".",
|
|
85
|
+
l: "debug",
|
|
86
|
+
c: "config.json",
|
|
87
|
+
r: "false",
|
|
88
|
+
setup: "setup.spec.json",
|
|
89
|
+
cleanup: "cleanup.spec.json",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
argSets.forEach((argSet) => {
|
|
94
|
+
expect(setArgs(argSet.args)).to.deep.include(argSet.expected);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Test that config overrides are set correctly
|
|
99
|
+
it("Config overrides are set correctly", function () {
|
|
100
|
+
configSets = [
|
|
101
|
+
{
|
|
102
|
+
// Input override
|
|
103
|
+
args: ["node", "runTests.js", "--input", "input.spec.json"],
|
|
104
|
+
expected: { input: "input.spec.json" },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// Input and logLevel overrides
|
|
108
|
+
args: [
|
|
109
|
+
"node",
|
|
110
|
+
"runTests.js",
|
|
111
|
+
"--input",
|
|
112
|
+
"input.spec.json",
|
|
113
|
+
"--logLevel",
|
|
114
|
+
"debug",
|
|
115
|
+
],
|
|
116
|
+
expected: { input: "input.spec.json", logLevel: "debug" },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
// Input, logLevel, and setup overrides
|
|
120
|
+
args: [
|
|
121
|
+
"node",
|
|
122
|
+
"runTests.js",
|
|
123
|
+
"--input",
|
|
124
|
+
"input.spec.json",
|
|
125
|
+
"--logLevel",
|
|
126
|
+
"debug",
|
|
127
|
+
"--setup",
|
|
128
|
+
"setup.spec.json",
|
|
129
|
+
],
|
|
130
|
+
expected: {
|
|
131
|
+
input: "input.spec.json",
|
|
132
|
+
logLevel: "debug",
|
|
133
|
+
runTests: { setup: "setup.spec.json" },
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
// Referenced config without overrides
|
|
138
|
+
args: ["node", "runTests.js", "--config", "./test/test-config.json"],
|
|
139
|
+
expected: {
|
|
140
|
+
input: ".",
|
|
141
|
+
output: ".",
|
|
142
|
+
logLevel: "silent",
|
|
143
|
+
recursive: true,
|
|
144
|
+
runTests: {
|
|
145
|
+
setup: ".",
|
|
146
|
+
cleanup: ".",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
// Referenced config with overrides
|
|
152
|
+
args: [
|
|
153
|
+
"node",
|
|
154
|
+
"runTests.js",
|
|
155
|
+
"--config",
|
|
156
|
+
"./test/test-config.json",
|
|
157
|
+
"--input",
|
|
158
|
+
"input.spec.json",
|
|
159
|
+
],
|
|
160
|
+
expected: {
|
|
161
|
+
input: "input.spec.json",
|
|
162
|
+
output: ".",
|
|
163
|
+
logLevel: "silent",
|
|
164
|
+
recursive: true,
|
|
165
|
+
runTests: {
|
|
166
|
+
setup: ".",
|
|
167
|
+
cleanup: ".",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
configSets.forEach((configSet) => {
|
|
174
|
+
const configResult = setConfig({}, setArgs(configSet.args));
|
|
175
|
+
deepObjectExpect(configResult, configSet.expected);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Test that results output correctly.
|
|
180
|
+
it("Results output correctly", async () => {
|
|
181
|
+
// Output test-results.json, make sure it exists, and clean it up.
|
|
182
|
+
const inputResultsPath = path.resolve("./test/test-results.json");
|
|
183
|
+
const inputResultsJSON = require(inputResultsPath);
|
|
184
|
+
const outputResultsPath = path.resolve("./test/output-test-results.json");
|
|
185
|
+
// Check that input file exists
|
|
186
|
+
expect(fs.existsSync(inputResultsPath)).to.equal(true);
|
|
187
|
+
// Output results
|
|
188
|
+
await outputResults(null, outputResultsPath, inputResultsJSON);
|
|
189
|
+
// Check that output file exists
|
|
190
|
+
expect(fs.existsSync(outputResultsPath)).to.equal(true);
|
|
191
|
+
// Clean up
|
|
192
|
+
fs.unlinkSync(outputResultsPath);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Deeply compares two objects
|
|
197
|
+
function deepObjectExpect(actual, expected) {
|
|
198
|
+
// Check that actual has all the keys of expected
|
|
199
|
+
Object.entries(expected).forEach(([key, value]) => {
|
|
200
|
+
// If value is an object, recursively check it
|
|
201
|
+
if (typeof value === "object") {
|
|
202
|
+
deepObjectExpect(actual[key], expected[key]);
|
|
203
|
+
} else {
|
|
204
|
+
// Otherwise, check that the value is correct
|
|
205
|
+
const expectedObject = {};
|
|
206
|
+
expectedObject[key] = value;
|
|
207
|
+
expect(actual).to.deep.include(expectedObject);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
package/.doc-detective.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"envVariables": "./samples/variables.env",
|
|
3
|
-
"input": ".",
|
|
4
|
-
"output": ".",
|
|
5
|
-
"recursive": true,
|
|
6
|
-
"logLevel": "info",
|
|
7
|
-
"runTests": {
|
|
8
|
-
"detectSteps": true,
|
|
9
|
-
"input": "./samples/doc-content.md",
|
|
10
|
-
"output": "./samples",
|
|
11
|
-
"recursive": true,
|
|
12
|
-
"mediaDirectory": "./samples",
|
|
13
|
-
"downloadDirectory": "./samples"
|
|
14
|
-
},
|
|
15
|
-
"fileTypes": [
|
|
16
|
-
{
|
|
17
|
-
"name": "Markdown",
|
|
18
|
-
"extensions": [".md"],
|
|
19
|
-
"testStartStatementOpen": "[comment]: # (test start",
|
|
20
|
-
"testStartStatementClose": ")",
|
|
21
|
-
"testIgnoreStatement": "[comment]: # (test ignore)",
|
|
22
|
-
"testEndStatement": "[comment]: # (test end)",
|
|
23
|
-
"stepStatementOpen": "[comment]: # (step",
|
|
24
|
-
"stepStatementClose": ")",
|
|
25
|
-
"markup": [
|
|
26
|
-
{
|
|
27
|
-
"name": "Hyperlink",
|
|
28
|
-
"regex": ["(?<=(?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
|
|
29
|
-
"actions": ["checkLink"]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"name": "Navigation link",
|
|
33
|
-
"regex": ["(?<=([Oo]pen|[Cc]lick) (?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
|
|
34
|
-
"actions": ["goTo"]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "Onscreen text",
|
|
38
|
-
"regex": ["(?<=\\*\\*)[\\w\\s]+?(?=\\*\\*)"],
|
|
39
|
-
"actions": ["find"]
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"name": "Image",
|
|
43
|
-
"regex": ["(?<=\\!\\[.*?\\]\\().*?(?=\\))"],
|
|
44
|
-
"actions": [
|
|
45
|
-
{
|
|
46
|
-
"name": "saveScreenshot",
|
|
47
|
-
"params": {
|
|
48
|
-
"directory": "samples",
|
|
49
|
-
"maxVariation": 5,
|
|
50
|
-
"overwrite": "byVariation"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"telemetry": {
|
|
59
|
-
"send": true,
|
|
60
|
-
"userId": "Doc Detective Repo"
|
|
61
|
-
},
|
|
62
|
-
"defaultCommand": "runTests"
|
|
63
|
-
}
|