doc-detective 2.11.4-dev.1 → 2.11.4-dev.2

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/.doc-detective.json +63 -63
  2. package/.github/FUNDING.yml +14 -14
  3. package/.github/dependabot.yml +11 -11
  4. package/.github/workflows/docker-image.yml +19 -19
  5. package/.github/workflows/electron-publish.yml +17 -17
  6. package/.github/workflows/npm-publish.yml +67 -67
  7. package/.github/workflows/npm-test.yaml +49 -49
  8. package/CONTRIBUTIONS.md +27 -27
  9. package/LICENSE +20 -20
  10. package/README.md +126 -126
  11. package/dev/dev.spec.json +62 -62
  12. package/dev/index.js +5 -5
  13. package/doc-detective.svg +26 -0
  14. package/package.json +44 -43
  15. package/samples/.doc-detective.json +82 -90
  16. package/samples/{doc-content.md → doc-content-detect.md} +10 -8
  17. package/samples/doc-content-inline-tests.md +28 -28
  18. package/samples/docker-hello.spec.json +14 -0
  19. package/samples/http.spec.json +26 -0
  20. package/samples/kitten-search-inline.md +15 -0
  21. package/samples/kitten-search.spec.json +28 -0
  22. package/samples/tests.spec.json +70 -70
  23. package/samples/variables.env +4 -4
  24. package/src/index.js +85 -85
  25. package/src/utils.js +190 -188
  26. package/test/artifacts/cleanup.spec.json +18 -18
  27. package/test/artifacts/config.json +46 -46
  28. package/test/artifacts/doc-content.md +17 -17
  29. package/test/artifacts/env +2 -2
  30. package/test/artifacts/httpRequest.spec.json +55 -55
  31. package/test/artifacts/runShell.spec.json +29 -29
  32. package/test/artifacts/setup.spec.json +18 -18
  33. package/test/artifacts/test.spec.json +60 -60
  34. package/test/runCoverage.test.js +18 -18
  35. package/test/runTests.test.js +22 -22
  36. package/test/test-config.json +12 -12
  37. package/test/test-results.json +124 -124
  38. package/test/utils.test.js +206 -204
@@ -1,125 +1,125 @@
1
- {
2
- "summary": {
3
- "specs": {
4
- "pass": 1,
5
- "fail": 0,
6
- "warning": 0,
7
- "skipped": 0
8
- },
9
- "tests": {
10
- "pass": 1,
11
- "fail": 0,
12
- "warning": 0,
13
- "skipped": 0
14
- },
15
- "contexts": {
16
- "pass": 1,
17
- "fail": 0,
18
- "warning": 0,
19
- "skipped": 0
20
- },
21
- "steps": {
22
- "pass": 6,
23
- "fail": 0,
24
- "warning": 0,
25
- "skipped": 0
26
- }
27
- },
28
- "specs": [
29
- {
30
- "result": "PASS",
31
- "id": "Do all the things! - Spec",
32
- "tests": [
33
- {
34
- "result": "PASS",
35
- "id": "Do all the things! - Test",
36
- "contexts": [
37
- {
38
- "result": "PASS",
39
- "app": "firefox",
40
- "platform": "linux",
41
- "steps": [
42
- {
43
- "result": "PASS",
44
- "resultDescription": "Set variables.",
45
- "action": "setVariables",
46
- "path": ".env",
47
- "id": "2606bcf3-2f45-4c4d-82a1-61392f5e8917"
48
- },
49
- {
50
- "result": "PASS",
51
- "resultDescription": "Executed command.",
52
- "action": "runShell",
53
- "command": "echo",
54
- "args": [
55
- "hawkeyexl"
56
- ],
57
- "id": "a15d25e8-6fa3-49c5-be3d-ae5aca0715e5"
58
- },
59
- {
60
- "result": "PASS",
61
- "resultDescription": "Returned 200",
62
- "action": "checkLink",
63
- "url": "https://www.duckduckgo.com",
64
- "id": "a4c44478-9756-4227-a63b-aa2d49aa4511",
65
- "statusCodes": [
66
- 200
67
- ]
68
- },
69
- {
70
- "result": "PASS",
71
- "resultDescription": "Returned 201. Expected response data was present in actual response data.",
72
- "action": "httpRequest",
73
- "url": "https://reqres.in/api/users",
74
- "method": "post",
75
- "requestData": {
76
- "name": "morpheus",
77
- "job": "leader"
78
- },
79
- "responseData": {
80
- "name": "morpheus",
81
- "job": "leader"
82
- },
83
- "statusCodes": [
84
- 200,
85
- 201
86
- ],
87
- "id": "fd520fd4-f32f-428b-a072-c2b2cffe3a3c",
88
- "requestHeaders": {},
89
- "responseHeaders": {},
90
- "requestParams": {},
91
- "responseParams": {},
92
- "envsFromResponseData": []
93
- },
94
- {
95
- "result": "PASS",
96
- "resultDescription": "Opened URL.",
97
- "action": "goTo",
98
- "url": "https://www.google.com",
99
- "id": "d6b47d3d-42db-45a7-8fde-3633adf30411"
100
- },
101
- {
102
- "result": "PASS",
103
- "resultDescription": "Found an element matching selector. Moved to element. Clicked element. Typed keys.",
104
- "action": "find",
105
- "selector": "[title=Search]",
106
- "timeout": 10000,
107
- "moveTo": true,
108
- "click": true,
109
- "typeKeys": {
110
- "keys": [
111
- "shorthair cat",
112
- "$ENTER$"
113
- ]
114
- },
115
- "id": "0d631a5b-6e96-4031-8d04-52d270f6e251"
116
- }
117
- ]
118
- }
119
- ],
120
- "description": "This test includes nearly every property across all actions."
121
- }
122
- ]
123
- }
124
- ]
1
+ {
2
+ "summary": {
3
+ "specs": {
4
+ "pass": 1,
5
+ "fail": 0,
6
+ "warning": 0,
7
+ "skipped": 0
8
+ },
9
+ "tests": {
10
+ "pass": 1,
11
+ "fail": 0,
12
+ "warning": 0,
13
+ "skipped": 0
14
+ },
15
+ "contexts": {
16
+ "pass": 1,
17
+ "fail": 0,
18
+ "warning": 0,
19
+ "skipped": 0
20
+ },
21
+ "steps": {
22
+ "pass": 6,
23
+ "fail": 0,
24
+ "warning": 0,
25
+ "skipped": 0
26
+ }
27
+ },
28
+ "specs": [
29
+ {
30
+ "result": "PASS",
31
+ "id": "Do all the things! - Spec",
32
+ "tests": [
33
+ {
34
+ "result": "PASS",
35
+ "id": "Do all the things! - Test",
36
+ "contexts": [
37
+ {
38
+ "result": "PASS",
39
+ "app": "firefox",
40
+ "platform": "linux",
41
+ "steps": [
42
+ {
43
+ "result": "PASS",
44
+ "resultDescription": "Set variables.",
45
+ "action": "setVariables",
46
+ "path": ".env",
47
+ "id": "2606bcf3-2f45-4c4d-82a1-61392f5e8917"
48
+ },
49
+ {
50
+ "result": "PASS",
51
+ "resultDescription": "Executed command.",
52
+ "action": "runShell",
53
+ "command": "echo",
54
+ "args": [
55
+ "hawkeyexl"
56
+ ],
57
+ "id": "a15d25e8-6fa3-49c5-be3d-ae5aca0715e5"
58
+ },
59
+ {
60
+ "result": "PASS",
61
+ "resultDescription": "Returned 200",
62
+ "action": "checkLink",
63
+ "url": "https://www.duckduckgo.com",
64
+ "id": "a4c44478-9756-4227-a63b-aa2d49aa4511",
65
+ "statusCodes": [
66
+ 200
67
+ ]
68
+ },
69
+ {
70
+ "result": "PASS",
71
+ "resultDescription": "Returned 201. Expected response data was present in actual response data.",
72
+ "action": "httpRequest",
73
+ "url": "https://reqres.in/api/users",
74
+ "method": "post",
75
+ "requestData": {
76
+ "name": "morpheus",
77
+ "job": "leader"
78
+ },
79
+ "responseData": {
80
+ "name": "morpheus",
81
+ "job": "leader"
82
+ },
83
+ "statusCodes": [
84
+ 200,
85
+ 201
86
+ ],
87
+ "id": "fd520fd4-f32f-428b-a072-c2b2cffe3a3c",
88
+ "requestHeaders": {},
89
+ "responseHeaders": {},
90
+ "requestParams": {},
91
+ "responseParams": {},
92
+ "envsFromResponseData": []
93
+ },
94
+ {
95
+ "result": "PASS",
96
+ "resultDescription": "Opened URL.",
97
+ "action": "goTo",
98
+ "url": "https://www.google.com",
99
+ "id": "d6b47d3d-42db-45a7-8fde-3633adf30411"
100
+ },
101
+ {
102
+ "result": "PASS",
103
+ "resultDescription": "Found an element matching selector. Moved to element. Clicked element. Typed keys.",
104
+ "action": "find",
105
+ "selector": "[title=Search]",
106
+ "timeout": 10000,
107
+ "moveTo": true,
108
+ "click": true,
109
+ "typeKeys": {
110
+ "keys": [
111
+ "shorthair cat",
112
+ "$ENTER$"
113
+ ]
114
+ },
115
+ "id": "0d631a5b-6e96-4031-8d04-52d270f6e251"
116
+ }
117
+ ]
118
+ }
119
+ ],
120
+ "description": "This test includes nearly every property across all actions."
121
+ }
122
+ ]
123
+ }
124
+ ]
125
125
  }
@@ -1,204 +1,206 @@
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 { 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
+ // Check that input file exists
182
+ expect(fs.existsSync(inputResultsPath)).to.equal(true);
183
+ // Output results
184
+ await outputResults(null, outputResultsPath, inputResultsJSON);
185
+ // Check that output file exists
186
+ expect(fs.existsSync(outputResultsPath)).to.equal(true);
187
+ // Clean up
188
+ fs.unlinkSync(outputResultsPath);
189
+ });
190
+ });
191
+
192
+ // Deeply compares two objects
193
+ function deepObjectExpect(actual, expected) {
194
+ // Check that actual has all the keys of expected
195
+ Object.entries(expected).forEach(([key, value]) => {
196
+ // If value is an object, recursively check it
197
+ if (typeof value === "object") {
198
+ deepObjectExpect(actual[key], expected[key]);
199
+ } else {
200
+ // Otherwise, check that the value is correct
201
+ const expectedObject = {};
202
+ expectedObject[key] = value;
203
+ expect(actual).to.deep.include(expectedObject);
204
+ }
205
+ });
206
+ }