doc-detective 1.0.0

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.
@@ -0,0 +1,112 @@
1
+ {
2
+ "version": "doc-unit-test version that ran the tests.",
3
+ "detailLevel": "How much detail is included in the analytics object. Values: ['parameter', 'action', 'test', 'run']",
4
+ "userId": "Optional. Identifier of the organization or individual running tests.",
5
+ "tests": {
6
+ "numberTests": "Total number of tests in a run.",
7
+ "passed": "Number of tests that passed",
8
+ "failed": "Number of tests that failed."
9
+ },
10
+ "actions": {
11
+ "numberActions": "Total number of actions in a run.",
12
+ "averageNumberActionsPerTest": "Average number of actions per test in a run.",
13
+ "minActionsPerTest": "Smallest number of actions in a test in a run.",
14
+ "maxActionsPerTest": "Largest number of actions in a tedt in a run",
15
+ "passed": "Number of actions that passed",
16
+ "failed": "Number of actions that failed."
17
+ },
18
+ "actionDetails": {
19
+ "goTo": {
20
+ "numberInstances": "How many instances of the action were present in tests.",
21
+ "passed": "Number of instances that passed.",
22
+ "failed": "Number of instances that failed.",
23
+ "uri": "Number of instances this setting was used."
24
+ },
25
+ "find": {
26
+ "numberInstances": "How many instances of the action were present in tests.",
27
+ "passed": "Number of instances that passed.",
28
+ "failed": "Number of instances that failed.",
29
+ "css": "Number of instances this setting was used."
30
+ },
31
+ "matchText": {
32
+ "numberInstances": "How many instances of the action were present in tests.",
33
+ "passed": "Number of instances that passed.",
34
+ "failed": "Number of instances that failed.",
35
+ "css": "Number of instances this setting was used.",
36
+ "text": "Number of instances this setting was used."
37
+ },
38
+ "click": {
39
+ "numberInstances": "How many instances of the action were present in tests.",
40
+ "passed": "Number of instances that passed.",
41
+ "failed": "Number of instances that failed.",
42
+ "css": "Number of instances this setting was used."
43
+ },
44
+ "type": {
45
+ "numberInstances": "How many instances of the action were present in tests.",
46
+ "passed": "Number of instances that passed.",
47
+ "failed": "Number of instances that failed.",
48
+ "css": "Number of instances this setting was used.",
49
+ "keys": "Number of instances this setting was used.",
50
+ "trailingSpecialKey": "Number of instances this setting was used."
51
+ },
52
+ "moveMouse": {
53
+ "numberInstances": "How many instances of the action were present in tests.",
54
+ "passed": "Number of instances that passed.",
55
+ "failed": "Number of instances that failed.",
56
+ "alignH": "Number of instances this setting was used.",
57
+ "alignV": "Number of instances this setting was used.",
58
+ "offsetX": "Number of instances this setting was used.",
59
+ "offsetY": "Number of instances this setting was used."
60
+ },
61
+ "scroll": {
62
+ "numberInstances": "How many instances of the action were present in tests.",
63
+ "passed": "Number of instances that passed.",
64
+ "failed": "Number of instances that failed.",
65
+ "x": "Number of instances this setting was used.",
66
+ "y": "Number of instances this setting was used."
67
+ },
68
+ "wait": {
69
+ "numberInstances": "How many instances of the action were present in tests.",
70
+ "passed": "Number of instances that passed.",
71
+ "failed": "Number of instances that failed.",
72
+ "duration": "Number of instances this setting was used."
73
+ },
74
+ "screenshot": {
75
+ "numberInstances": "How many instances of the action were present in tests.",
76
+ "passed": "Number of instances that passed.",
77
+ "failed": "Number of instances that failed.",
78
+ "mediaDirectory": "Number of instances this setting was used.",
79
+ "filename": "Number of instances this setting was used.",
80
+ "matchPrevious": "Number of instances this setting was used.",
81
+ "matchThreshold": "Number of instances this setting was used."
82
+ },
83
+ "startRecording": {
84
+ "numberInstances": "How many instances of the action were present in tests.",
85
+ "passed": "Number of instances that passed.",
86
+ "failed": "Number of instances that failed.",
87
+ "mediaDirectory": "Number of instances this setting was used.",
88
+ "filename": "Number of instances this setting was used.",
89
+ "gifFps": "Number of instances this setting was used.",
90
+ "gifWidth": "Number of instances this setting was used."
91
+ },
92
+ "stopRecording": {
93
+ "numberInstances": "How many instances of the action were present in tests.",
94
+ "passed": "Number of instances that passed.",
95
+ "failed": "Number of instances that failed."
96
+ },
97
+ "checkLink": {
98
+ "numberInstances": "How many instances of the action were present in tests.",
99
+ "passed": "Number of instances that passed.",
100
+ "failed": "Number of instances that failed.",
101
+ "uri": "Number of instances this setting was used.",
102
+ "statusCodes": "Number of instances this setting was used."
103
+ },
104
+ "runShell": {
105
+ "numberInstances": "How many instances of the action were present in tests.",
106
+ "passed": "Number of instances that passed.",
107
+ "failed": "Number of instances that failed.",
108
+ "command": "Number of instances this setting was used.",
109
+ "env": "Number of instances this setting was used."
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "id": "Optional. ID of the test. Must be unique. Generated UUID if not specified.",
5
+ "file": "Output only. File the test is defined in. All actions for a given test must be defined in a single file.",
6
+ "status": "Output only. The status of the test based on test action results. Possible values: PASS, WARNING, FAIL",
7
+ "actions": [
8
+ {
9
+ "action": "Required. Task to perform. Supported values: goTo, find, matchText, click, type, wait, screenshot",
10
+ "alignH": "Optional. Applicable actions: moveMouse, find. Horizantal alignment of the mouse to the element. Accepted values: left, center, right",
11
+ "alignV": "Optional. Applicable actions: moveMouse, find. Vertical alignment of the mouse to the element. Accepted values: top, center, bottom",
12
+ "css": "Required for the following actions: find, matchText, click, type, moveMouse. CSS selectors that resolve to the element. Only returns the first element that matches the selectors.",
13
+ "duration": "Optional. Applicable actions: wait. How long to wait in milliseconds.",
14
+ "filename": "Optional. Applicable actions: screenshot. Name of the media file. If not specified, the filename is randomized.",
15
+ "gifFps": "Optional. Application action: startRecording. Frames per second of the output GIF file.",
16
+ "gifWidth": "Optional. Application action: startRecording. Width of the output GIF file.",
17
+ "keys": "Optional. Applicable actions: type, find. Strings of keys of enter. To send special keys like 'ENTER', see 'trailingSpecialKey'.",
18
+ "line": "Output only. Line number that the test action definition begins on.",
19
+ "mediaDirectory": "Optional. Applicable actions: screenshot. The directory path for media created by the action. Overrides the default directory config. Default is config.imageDirectory or config.videoDirectory depending on the file type.",
20
+ "offsetX": "Optional. Applicable actions: moveMouse, find. How many pixels to offset the mouse along the X axis, relative to the element center.",
21
+ "offsetY": "Optional. Applicable actions: moveMouse, find. How many pixels to offset the mouse along the Y axis, relative to the element center.",
22
+ "statusCodes": "Optional. Applicable action: checkLink. The HTTP status codes accepted from makeing a GET request to the specified URI.",
23
+ "testId": "Optional. Input only. Only valid for non-JSON test files. ID of the test the action belongs to.",
24
+ "text": "Required. Applicable actions: matchText, find. Exact text expected to display in the element.",
25
+ "trailingSpecialKey": "Optional. Applicable actions: type, find. A special key pressed after the 'keys' value, if present. Supported values: https://github.com/puppeteer/puppeteer/blob/main/src/common/USKeyboardLayout.ts",
26
+ "uri": "Required. Applicable actions: goTo, checkLink. URI to check or to navigate to in the browser.",
27
+ "result": {
28
+ "status": "Output only. Status based on test action results. Possible values: PASS, WARNING, FAIL",
29
+ "description": "Output only. Explaination of the action result.",
30
+ "image": "Output only. File path for an output image.",
31
+ "video": "Output only. File path for an output video."
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "env": "sample/variables.env",
3
+ "input": "sample/doc-content.md",
4
+ "output": "sample/results.json",
5
+ "recursive": true,
6
+ "testExtensions": [
7
+ ".md",
8
+ ".mdx",
9
+ ".html",
10
+ ".htm",
11
+ ".xml",
12
+ ".json"
13
+ ],
14
+ "mediaDirectory": "sample",
15
+ "fileTypes": [
16
+ {
17
+ "extensions": [
18
+ ".md",
19
+ ".mdx"
20
+ ],
21
+ "openTestStatement": "[comment]: # (test",
22
+ "closeTestStatement": ")"
23
+ },
24
+ {
25
+ "extensions": [
26
+ ".html",
27
+ ".htm",
28
+ ".xml"
29
+ ],
30
+ "openTestStatement": "<!-- test",
31
+ "closeTestStatement": "-->"
32
+ }
33
+ ],
34
+ "browserOptions": {
35
+ "headless": "true",
36
+ "path": "",
37
+ "height": 600,
38
+ "width": 800
39
+ },
40
+ "analytics": {
41
+ "send": false,
42
+ "userId": "",
43
+ "detailLevel": "action-detailed",
44
+ "customServers": []
45
+ },
46
+ "logLevel": "info"
47
+ }
@@ -0,0 +1,42 @@
1
+ # Search for kittens
2
+
3
+ To use Google Search to find information on kittens,
4
+
5
+ 1. Open [Google Search](https://www.google.com).
6
+
7
+ [comment]: # (test {"testId":"process-search-kittens", "action":"startRecording", "filename":"results.gif", "gifFps":15, "gifWidth":300})
8
+ [comment]: # (test {"testId":"process-search-kittens", "action":"goTo", "uri":"www.google.com"})
9
+
10
+ 2. In the search bar, enter "kittens", then press Enter.
11
+
12
+ [comment]: # (test {"testId":"process-search-kittens", "action":"moveMouse", "css":"#gbqfbb", "alignH": "center", "alignV": "center"})
13
+ [comment]: # (test {"testId":"process-search-kittens", "action":"wait", "duration":"5000"})
14
+ [comment]: # (test {"testId":"process-search-kittens", "action":"moveMouse", "css":"[title=Search]", "alignV": "center"})
15
+ [comment]: # (test {"testId":"process-search-kittens", "action":"type", "css":"[title=Search]", "keys":"kittens", "trailingSpecialKey":"Enter"})
16
+ [comment]: # (test {"testId":"process-search-kittens", "action":"wait", "duration":"5000"})
17
+ [comment]: # (test {"testId":"process-search-kittens", "action":"scroll", "y": 300})
18
+ [comment]: # (test {"testId":"process-search-kittens", "action":"stopRecording"})
19
+ [comment]: # (test {"testId":"process-search-kittens", "action":"screenshot", "filename":"results.png", "matchPrevious": true, "matchThreshold": 0.1})
20
+
21
+ Search results appear on the page.
22
+
23
+ ![Search results for 'kittens'.](results.png)
24
+
25
+ ## Recommended results
26
+
27
+ To go directly to a recommended result for your search, use the **I'm Feeling Lucky** button. If you're searching for american shorthair information,
28
+
29
+ [comment]: # (test {"testId":"text-match-lucky", "action":"goTo", "uri":"www.google.com"})
30
+ [comment]: # (test {"testId":"text-match-lucky", "action":"matchText", "css":"#gbqfbb", "text":"I'm Feeling Lucky"})
31
+
32
+ 1. Open [Google Search](https://www.google.com).
33
+
34
+ [comment]: # (test {"testId":"process-lucky-shorthair", "action":"goTo", "uri":"www.google.com"})
35
+
36
+ 2. In the search bar, enter "american shorthair cats".
37
+
38
+ [comment]: # (test {"testId":"process-lucky-shorthair", "action":"type", "css":"[title=Search]", "keys":"american shorthair cats"})
39
+
40
+ 3. Click **I'm Feeling Lucky**.
41
+
42
+ [comment]: # (test {"testId":"process-lucky-shorthair", "action":"click", "css":"#gbqfbb"})
@@ -0,0 +1,36 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "id": "process-lucky-shorthair",
5
+ "actions": [
6
+ {
7
+ "action": "goTo",
8
+ "uri": "www.google.com",
9
+ "result": {
10
+ "status": "PASS",
11
+ "description": "Opened URI."
12
+ }
13
+ },
14
+ {
15
+ "action": "type",
16
+ "css": "[title=Search]",
17
+ "keys": "american shorthair cats",
18
+ "result": {
19
+ "status": "PASS",
20
+ "description": "Typed keys."
21
+ }
22
+ },
23
+ {
24
+ "action": "click",
25
+ "moveMouse": true,
26
+ "css": "#gbqfbb",
27
+ "result": {
28
+ "status": "PASS",
29
+ "description": "Clicked element."
30
+ }
31
+ }
32
+ ],
33
+ "status": "PASS"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "id": "process-search-kittens",
5
+ "actions": [
6
+ {
7
+ "action": "goTo",
8
+ "uri": "www.google.com"
9
+ },
10
+ {
11
+ "action": "type",
12
+ "css": "[title=Search]",
13
+ "keys": "kittens",
14
+ "trailingSpecialKey": "Enter"
15
+ },
16
+ {
17
+ "action": "wait",
18
+ "duration": "5000"
19
+ },
20
+ {
21
+ "action": "screenshot",
22
+ "filename": "results.png",
23
+ "matchPrevious": true,
24
+ "matchThreshold": 0.1
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "id": "text-match-lucky",
30
+ "actions": [
31
+ {
32
+ "action": "goTo",
33
+ "uri": "www.google.com"
34
+ },
35
+ {
36
+ "action": "matchText",
37
+ "css": "#gbqfbb",
38
+ "text": "I'm Feeling Lucky"
39
+ },
40
+ {
41
+ "action": "matchText",
42
+ "css": "#gbqfbb",
43
+ "text": "$TEXT",
44
+ "env": "./sample/variables.env"
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "id": "process-lucky-shorthair",
50
+ "actions": [
51
+ {
52
+ "action": "goTo",
53
+ "uri": "$URL",
54
+ "env": "./sample/variables.env"
55
+ },
56
+ {
57
+ "action": "type",
58
+ "css": "[title=Search]",
59
+ "keys": "$SHORTHAIR_CAT_SEARCH"
60
+ },
61
+ {
62
+ "action": "click",
63
+ "css": "#gbqfbb"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "id": "non-ui-tests",
69
+ "actions": [
70
+ {
71
+ "action": "runShell",
72
+ "command": "echo $USERNAME",
73
+ "env": "./sample/variables.env"
74
+ },
75
+ {
76
+ "action": "checkLink",
77
+ "uri": "https://www.google.com",
78
+ "statusCodes": [
79
+ 200
80
+ ]
81
+ },
82
+ {
83
+ "action": "checkLink",
84
+ "uri": "$URL",
85
+ "statusCodes": [
86
+ 200
87
+ ]
88
+ }
89
+ ]
90
+ }
91
+ ]
92
+ }
@@ -0,0 +1,5 @@
1
+ USERNAME=foo
2
+ PASSWORD=bar
3
+ SHORTHAIR_CAT_SEARCH=american shorthair cats
4
+ URL=www.google.com
5
+ TEXT=I'm Feeling Lucky
@@ -0,0 +1,47 @@
1
+ {
2
+ "env": "",
3
+ "input": ".",
4
+ "output": "./results.json",
5
+ "recursive": true,
6
+ "testExtensions": [
7
+ ".md",
8
+ ".mdx",
9
+ ".html",
10
+ ".htm",
11
+ ".xml",
12
+ ".json"
13
+ ],
14
+ "mediaDirectory": ".",
15
+ "fileTypes": [
16
+ {
17
+ "extensions": [
18
+ ".md",
19
+ ".mdx"
20
+ ],
21
+ "openTestStatement": "[comment]: # (test",
22
+ "closeTestStatement": ")"
23
+ },
24
+ {
25
+ "extensions": [
26
+ ".html",
27
+ ".htm",
28
+ ".xml"
29
+ ],
30
+ "openTestStatement": "<!-- test",
31
+ "closeTestStatement": "-->"
32
+ }
33
+ ],
34
+ "browserOptions": {
35
+ "headless": "true",
36
+ "path": "",
37
+ "height": 800,
38
+ "width": 1200
39
+ },
40
+ "analytics": {
41
+ "send": false,
42
+ "userId": "",
43
+ "detailLevel": "action-detailed",
44
+ "customServers": []
45
+ },
46
+ "logLevel": "info"
47
+ }
package/src/index.js ADDED
@@ -0,0 +1,51 @@
1
+ const {
2
+ setArgs,
3
+ setConfig,
4
+ setFiles,
5
+ parseFiles,
6
+ outputResults,
7
+ log,
8
+ } = require("./lib/utils");
9
+ const { sendAnalytics } = require("./lib/analytics.js");
10
+ const { runTests } = require("./lib/tests");
11
+
12
+ exports.run = function (config, argv) {
13
+ main(config, argv);
14
+ };
15
+
16
+ async function main(config, argv) {
17
+ // Set args
18
+ argv = setArgs(argv);
19
+ log(config, "debug", `ARGV:`);
20
+ log(config, "debug", argv);
21
+
22
+ // Set config
23
+ config = setConfig(config, argv);
24
+ log(config, "debug", `CONFIG:`);
25
+ log(config, "debug", config);
26
+
27
+ // Set files
28
+ const files = setFiles(config);
29
+ log(config, "debug", `FILES:`);
30
+ log(config, "debug", files);
31
+
32
+ // Set tests
33
+ const tests = parseFiles(config, files);
34
+ if (config.logLevel === "debug") {
35
+ console.log("(DEBUG) TESTS:");
36
+ tests.tests.forEach((test) => {
37
+ console.log(test);
38
+ });
39
+ }
40
+
41
+ // Run tests
42
+ const results = await runTests(config, tests);
43
+ log(config, "debug", `RESULTS:`);
44
+ log(config, "debug", results);
45
+
46
+ // Output
47
+ outputResults(config, results);
48
+ if (config.analytics.send) {
49
+ sendAnalytics(config, results);
50
+ }
51
+ }