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.
Files changed (38) hide show
  1. package/.github/FUNDING.yml +14 -14
  2. package/.github/dependabot.yml +11 -11
  3. package/.github/workflows/docker-image.yml +19 -19
  4. package/.github/workflows/electron-publish.yml +17 -17
  5. package/.github/workflows/npm-publish.yml +67 -67
  6. package/.github/workflows/npm-test.yaml +49 -49
  7. package/CONTRIBUTIONS.md +27 -27
  8. package/LICENSE +20 -20
  9. package/README.md +126 -126
  10. package/dev/dev.spec.json +62 -62
  11. package/dev/index.js +5 -5
  12. package/doc-detective.svg +26 -0
  13. package/package.json +44 -43
  14. package/samples/.doc-detective.json +82 -90
  15. package/samples/{doc-content.md → doc-content-detect.md} +10 -8
  16. package/samples/doc-content-inline-tests.md +28 -28
  17. package/samples/docker-hello.spec.json +14 -0
  18. package/samples/http.spec.json +26 -0
  19. package/samples/kitten-search-inline.md +15 -0
  20. package/samples/kitten-search.spec.json +28 -0
  21. package/samples/tests.spec.json +70 -70
  22. package/samples/variables.env +4 -4
  23. package/src/index.js +84 -84
  24. package/src/utils.js +190 -188
  25. package/test/artifacts/cleanup.spec.json +18 -18
  26. package/test/artifacts/config.json +42 -42
  27. package/test/artifacts/doc-content.md +17 -17
  28. package/test/artifacts/env +2 -2
  29. package/test/artifacts/httpRequest.spec.json +55 -55
  30. package/test/artifacts/runShell.spec.json +29 -29
  31. package/test/artifacts/setup.spec.json +18 -18
  32. package/test/artifacts/test.spec.json +60 -60
  33. package/test/runCoverage.test.js +24 -18
  34. package/test/runTests.test.js +29 -22
  35. package/test/test-config.json +12 -12
  36. package/test/test-results.json +124 -124
  37. package/test/utils.test.js +210 -204
  38. package/.doc-detective.json +0 -63
@@ -1,204 +1,210 @@
1
- const { setArgs, setConfig, outputResults } = require("../src/utils");
2
- const path = require("path");
3
- const { expect, should, assert } = require("chai");
4
- const fs = require("fs");
5
-
6
- describe("Util tests", function () {
7
- // Test that arguments are parsed correctly
8
- it("Yargs parses arguments correctly", function () {
9
- const argSets = [
10
- {
11
- args: ["node", "runTests.js", "--input", "input.spec.json"],
12
- expected: { i: "input.spec.json" },
13
- },
14
- {
15
- args: [
16
- "node",
17
- "runTests.js",
18
- "--input",
19
- "input.spec.json",
20
- "--logLevel",
21
- "debug",
22
- ],
23
- expected: { i: "input.spec.json", l: "debug" },
24
- },
25
- {
26
- args: [
27
- "node",
28
- "runTests.js",
29
- "--input",
30
- "input.spec.json",
31
- "--logLevel",
32
- "debug",
33
- "--config",
34
- "config.json",
35
- ],
36
-
37
- expected: { i: "input.spec.json", l: "debug", c: "config.json" },
38
- },
39
- {
40
- args: [
41
- "node",
42
- "runTests.js",
43
- "--input",
44
- "input.spec.json",
45
- "--output",
46
- ".",
47
- "--logLevel",
48
- "debug",
49
- "--config",
50
- "config.json",
51
- ],
52
- expected: {
53
- i: "input.spec.json",
54
- o: ".",
55
- l: "debug",
56
- c: "config.json",
57
- },
58
- },
59
- {
60
- args: [
61
- "node",
62
- "runTests.js",
63
- "--input",
64
- "input.spec.json",
65
- "--output",
66
- ".",
67
- "--logLevel",
68
- "debug",
69
- "--config",
70
- "config.json",
71
- "--recursive",
72
- "false",
73
- "--setup",
74
- "setup.spec.json",
75
- "--cleanup",
76
- "cleanup.spec.json",
77
- ],
78
- expected: {
79
- i: "input.spec.json",
80
- o: ".",
81
- l: "debug",
82
- c: "config.json",
83
- r: "false",
84
- setup: "setup.spec.json",
85
- cleanup: "cleanup.spec.json",
86
- },
87
- },
88
- ];
89
- argSets.forEach((argSet) => {
90
- expect(setArgs(argSet.args)).to.deep.include(argSet.expected);
91
- });
92
- });
93
-
94
- // Test that config overrides are set correctly
95
- it("Config overrides are set correctly", function () {
96
- configSets = [
97
- {
98
- // Input override
99
- args: ["node", "runTests.js", "--input", "input.spec.json"],
100
- expected: { input: "input.spec.json" },
101
- },
102
- {
103
- // Input and logLevel overrides
104
- args: [
105
- "node",
106
- "runTests.js",
107
- "--input",
108
- "input.spec.json",
109
- "--logLevel",
110
- "debug",
111
- ],
112
- expected: { input: "input.spec.json", logLevel: "debug" },
113
- },
114
- {
115
- // Input, logLevel, and setup overrides
116
- args: [
117
- "node",
118
- "runTests.js",
119
- "--input",
120
- "input.spec.json",
121
- "--logLevel",
122
- "debug",
123
- "--setup",
124
- "setup.spec.json",
125
- ],
126
- expected: {
127
- input: "input.spec.json",
128
- logLevel: "debug",
129
- runTests: { setup: "setup.spec.json" },
130
- },
131
- },
132
- {
133
- // Referenced config without overrides
134
- args: ["node", "runTests.js", "--config", "./test/test-config.json"],
135
- expected: {
136
- input: ".",
137
- output: ".",
138
- logLevel: "silent",
139
- recursive: true,
140
- runTests: {
141
- setup: ".",
142
- cleanup: ".",
143
- },
144
- },
145
- },
146
- {
147
- // Referenced config with overrides
148
- args: [
149
- "node",
150
- "runTests.js",
151
- "--config",
152
- "./test/test-config.json",
153
- "--input",
154
- "input.spec.json",
155
- ],
156
- expected: {
157
- input: "input.spec.json",
158
- output: ".",
159
- logLevel: "silent",
160
- recursive: true,
161
- runTests: {
162
- setup: ".",
163
- cleanup: ".",
164
- },
165
- },
166
- },
167
- ];
168
-
169
- configSets.forEach((configSet) => {
170
- const configResult = setConfig({}, setArgs(configSet.args));
171
- deepObjectExpect(configResult, configSet.expected);
172
- });
173
- });
174
-
175
- // Test that results output correctly.
176
- it("Results output correctly", async () => {
177
- // Output test-results.json, make sure it exists, and clean it up.
178
- const inputResultsPath = path.resolve("./test/test-results.json");
179
- const inputResultsJSON = require(inputResultsPath);
180
- const outputResultsPath = path.resolve("./test/output-test-results.json");
181
- // Output results
182
- await outputResults(null, outputResultsPath, inputResultsJSON);
183
- // Check that output file exists
184
- expect(fs.existsSync(outputResultsPath)).to.equal(true);
185
- // Clean up
186
- fs.unlinkSync(outputResultsPath);
187
- });
188
- });
189
-
190
- // Deeply compares two objects
191
- function deepObjectExpect(actual, expected) {
192
- // Check that actual has all the keys of expected
193
- Object.entries(expected).forEach(([key, value]) => {
194
- // If value is an object, recursively check it
195
- if (typeof value === "object") {
196
- deepObjectExpect(actual[key], expected[key]);
197
- } else {
198
- // Otherwise, check that the value is correct
199
- const expectedObject = {};
200
- expectedObject[key] = value;
201
- expect(actual).to.deep.include(expectedObject);
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
+ }
@@ -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
- }