@w-lfpup/jackrabbit 0.1.0 → 0.3.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.
- package/.github/workflows/browsers.json +45 -0
- package/.github/workflows/browsers.macos.json +51 -0
- package/.github/workflows/browsers.windows.json +19 -0
- package/.github/workflows/tests.yml +42 -0
- package/README.md +151 -8
- package/browser/dist/logger.js +43 -0
- package/browser/dist/mod.js +26 -0
- package/browser/dist/queue.js +27 -0
- package/browser/dist/runner.js +20 -0
- package/{cli → browser}/package.json +1 -1
- package/browser/src/logger.ts +57 -0
- package/browser/src/mod.ts +30 -0
- package/browser/src/runner.ts +22 -0
- package/browser/tsconfig.json +11 -0
- package/browser/tsconfig.tsbuildinfo +1 -0
- package/browsers.json +38 -0
- package/core/dist/jackrabbit_types.d.ts +62 -28
- package/core/dist/mod.d.ts +2 -2
- package/core/dist/mod.js +1 -1
- package/core/dist/run_steps.d.ts +2 -2
- package/core/dist/run_steps.js +83 -67
- package/core/src/jackrabbit_types.ts +73 -29
- package/core/src/mod.ts +2 -8
- package/core/src/run_steps.ts +111 -80
- package/examples/hello_world/goodbye_world.ts +1 -1
- package/examples/hello_world/hello_world.ts +1 -1
- package/nodejs/dist/logger.js +161 -0
- package/nodejs/dist/mod.js +31 -0
- package/nodejs/dist/results.js +139 -0
- package/nodejs/dist/results_str.js +147 -0
- package/nodejs/dist/runner.js +17 -0
- package/nodejs/src/logger.ts +193 -0
- package/nodejs/src/mod.ts +37 -0
- package/nodejs/src/results_str.ts +234 -0
- package/{cli → nodejs}/tsconfig.json +2 -1
- package/nodejs/tsconfig.tsbuildinfo +1 -0
- package/package.json +9 -6
- package/tests/dist/mod.d.ts +14 -3
- package/tests/dist/mod.js +33 -13
- package/tests/dist/test_error.test.d.ts +9 -0
- package/tests/dist/test_error.test.js +27 -0
- package/tests/dist/test_errors.test.d.ts +9 -0
- package/tests/dist/test_errors.test.js +27 -0
- package/tests/dist/test_logger.d.ts +3 -2
- package/tests/dist/test_logger.js +5 -1
- package/tests/src/mod.ts +31 -15
- package/tests/src/test_error.test.ts +32 -0
- package/tests/src/test_logger.ts +6 -1
- package/tests/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +1 -1
- package/webdriver/dist/config.js +57 -0
- package/webdriver/dist/eventbus.js +18 -0
- package/webdriver/dist/listeners.js +21 -0
- package/webdriver/dist/logger.js +203 -0
- package/webdriver/dist/mod.js +36 -0
- package/webdriver/dist/results_str.js +167 -0
- package/webdriver/dist/routes.js +172 -0
- package/webdriver/dist/routes2.js +163 -0
- package/webdriver/dist/test_hangar.js +20 -0
- package/webdriver/dist/webdriver.js +273 -0
- package/webdriver/package.json +8 -0
- package/webdriver/src/config.ts +89 -0
- package/webdriver/src/eventbus.ts +104 -0
- package/webdriver/src/logger.ts +247 -0
- package/webdriver/src/mod.ts +43 -0
- package/webdriver/src/results.ts +56 -0
- package/webdriver/src/results_str.ts +222 -0
- package/webdriver/src/routes.ts +211 -0
- package/webdriver/src/test_hangar.ts +25 -0
- package/webdriver/src/webdriver.ts +372 -0
- package/{nodejs_cli → webdriver}/tsconfig.json +1 -0
- package/webdriver/tsconfig.tsbuildinfo +1 -0
- package/.github/workflows/build_and_test.yml +0 -18
- package/cli/dist/cli.d.ts +0 -3
- package/cli/dist/cli.js +0 -8
- package/cli/dist/cli_types.d.ts +0 -7
- package/cli/dist/config.d.ts +0 -5
- package/cli/dist/config.js +0 -27
- package/cli/dist/importer.d.ts +0 -7
- package/cli/dist/importer.js +0 -16
- package/cli/dist/logger.d.ts +0 -7
- package/cli/dist/logger.js +0 -88
- package/cli/dist/mod.d.ts +0 -6
- package/cli/dist/mod.js +0 -4
- package/cli/src/cli.ts +0 -17
- package/cli/src/cli_types.ts +0 -9
- package/cli/src/config.ts +0 -36
- package/cli/src/importer.ts +0 -25
- package/cli/src/logger.ts +0 -126
- package/cli/src/mod.ts +0 -7
- package/cli/tsconfig.tsbuildinfo +0 -1
- package/nodejs_cli/dist/mod.d.ts +0 -2
- package/nodejs_cli/dist/mod.js +0 -20
- package/nodejs_cli/src/mod.ts +0 -25
- package/nodejs_cli/tsconfig.tsbuildinfo +0 -1
- package/test_guide.md +0 -114
- /package/{nodejs_cli → nodejs}/package.json +0 -0
- /package/{cli/dist/cli_types.js → webdriver/dist/results.js} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host_and_port": "http://127.0.0.1:4000",
|
|
3
|
+
"runAsynchronusly": false,
|
|
4
|
+
"webdrivers": [
|
|
5
|
+
{
|
|
6
|
+
"command": "$GECKOWEBDRIVER/geckodriver -p 4001",
|
|
7
|
+
"title": "Firefox",
|
|
8
|
+
"timeout_ms": 30000,
|
|
9
|
+
"url": "http://localhost:4001",
|
|
10
|
+
"capabilities": {
|
|
11
|
+
"alwaysMatch": {
|
|
12
|
+
"moz:firefoxOptions": {
|
|
13
|
+
"args": ["-headless"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"command": "$CHROMEWEBDRIVER/chromedriver --port=4005",
|
|
20
|
+
"title": "Chrome",
|
|
21
|
+
"timeout_ms": 30000,
|
|
22
|
+
"url": "http://localhost:4005",
|
|
23
|
+
"capabilities": {
|
|
24
|
+
"alwaysMatch": {
|
|
25
|
+
"goog:chromeOptions": {
|
|
26
|
+
"args": ["--headless"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"command": "$EDGEWEBDRIVER/msedgedriver --port=4010",
|
|
33
|
+
"title": "Edge",
|
|
34
|
+
"timeout_ms": 30000,
|
|
35
|
+
"url": "http://localhost:4010",
|
|
36
|
+
"capabilities": {
|
|
37
|
+
"alwaysMatch": {
|
|
38
|
+
"ms:edgeOptions": {
|
|
39
|
+
"args": ["--headless", "--disable-dev-shm-usage"]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host_and_port": "http://127.0.0.1:4000",
|
|
3
|
+
"runAsynchronusly": false,
|
|
4
|
+
"webdrivers": [
|
|
5
|
+
{
|
|
6
|
+
"command": "safaridriver -p 4001",
|
|
7
|
+
"title": "Safari",
|
|
8
|
+
"timeout_ms": 30000,
|
|
9
|
+
"url": "http://localhost:4001"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"command": "$GECKOWEBDRIVER/geckodriver -p 4001",
|
|
13
|
+
"title": "Firefox",
|
|
14
|
+
"timeout_ms": 30000,
|
|
15
|
+
"url": "http://127.0.0.1:4001",
|
|
16
|
+
"capabilities": {
|
|
17
|
+
"alwaysMatch": {
|
|
18
|
+
"moz:firefoxOptions": {
|
|
19
|
+
"args": ["-headless"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"command": "$CHROMEWEBDRIVER/chromedriver --port=4001",
|
|
26
|
+
"title": "Chrome",
|
|
27
|
+
"timeout_ms": 30000,
|
|
28
|
+
"url": "http://localhost:4001",
|
|
29
|
+
"capabilities": {
|
|
30
|
+
"alwaysMatch": {
|
|
31
|
+
"goog:chromeOptions": {
|
|
32
|
+
"args": ["--headless"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"command": "$EDGEWEBDRIVER/msedgedriver --port=4001",
|
|
39
|
+
"title": "Edge",
|
|
40
|
+
"timeout_ms": 30000,
|
|
41
|
+
"url": "http://localhost:4001",
|
|
42
|
+
"capabilities": {
|
|
43
|
+
"alwaysMatch": {
|
|
44
|
+
"ms:edgeOptions": {
|
|
45
|
+
"args": ["--headless"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host_and_port": "http://127.0.0.1:4000",
|
|
3
|
+
"runAsynchronusly": false,
|
|
4
|
+
"webdrivers": [
|
|
5
|
+
{
|
|
6
|
+
"command": "$Env:GECKOWEBDRIVER\\geckodriver.exe -p 4001",
|
|
7
|
+
"title": "Firefox",
|
|
8
|
+
"timeout_ms": 20000,
|
|
9
|
+
"url": "http://127.0.0.1:4001",
|
|
10
|
+
"capabilities": {
|
|
11
|
+
"alwaysMatch": {
|
|
12
|
+
"moz:firefoxOptions": {
|
|
13
|
+
"args": ["-headless"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build_and_test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
- uses: actions/setup-node@v6
|
|
15
|
+
- name: Install
|
|
16
|
+
run: npm ci
|
|
17
|
+
- name: Test
|
|
18
|
+
run: npm run test
|
|
19
|
+
- name: Test browsers
|
|
20
|
+
run: npx jackrabbit_webdriver .github/workflows/browsers.json ./tests/dist/mod.js
|
|
21
|
+
build_and_test_macos:
|
|
22
|
+
runs-on: macos-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v6
|
|
25
|
+
- uses: actions/setup-node@v6
|
|
26
|
+
- name: Install
|
|
27
|
+
run: npm ci
|
|
28
|
+
- name: Test
|
|
29
|
+
run: npm run test
|
|
30
|
+
- name: Test browsers
|
|
31
|
+
run: npx jackrabbit_webdriver .github/workflows/browsers.macos.json ./tests/dist/mod.js
|
|
32
|
+
# build_and_test_windows:
|
|
33
|
+
# runs-on: windows-latest
|
|
34
|
+
# steps:
|
|
35
|
+
# - uses: actions/checkout@v6
|
|
36
|
+
# - uses: actions/setup-node@v6
|
|
37
|
+
# - name: Install
|
|
38
|
+
# run: npm ci
|
|
39
|
+
# - name: Test
|
|
40
|
+
# run: npm run test
|
|
41
|
+
# - name: Test browsers
|
|
42
|
+
# run: npx jackrabbit_webdriver .github/workflows/browsers.windows.json ./tests/dist/mod.js
|
package/README.md
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Write tests without dependencies (including jackrabbit itself).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Read [this guide](./test_guide.md) to create jackrabbit tests.
|
|
5
|
+
[](https://github.com/w-lfpup/jackrabbit-js/actions/workflows/tests.yml)
|
|
8
6
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
### Install
|
|
7
|
+
## Install
|
|
12
8
|
|
|
13
9
|
Install jackrabbit with npm.
|
|
14
10
|
|
|
@@ -22,10 +18,157 @@ Or Install jackrabbit directly from github.
|
|
|
22
18
|
npm install --save-dev https://github.com/w-lfpup/jackrabbit-js
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
# Tests
|
|
22
|
+
|
|
23
|
+
For a quick visual reference, please refer to the [examples](./examples/).
|
|
24
|
+
|
|
25
|
+
Developers with javascript experience can immediately start testing with basically zero overhead.
|
|
26
|
+
|
|
27
|
+
## Tests
|
|
28
|
+
|
|
29
|
+
Tests are functions or promises that return assertions.
|
|
30
|
+
|
|
31
|
+
Tests `pass` when they return the `undefined` primitive or an empty array `[]`.
|
|
32
|
+
|
|
33
|
+
```TS
|
|
34
|
+
// my.tests.ts
|
|
35
|
+
|
|
36
|
+
function testStuffAndPass() {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function testMoreStuffAndPass() {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Any other value will cause a test to `fail`.
|
|
46
|
+
|
|
47
|
+
So tests that `fail` look like:
|
|
48
|
+
|
|
49
|
+
```TS
|
|
50
|
+
// my.tests.ts
|
|
51
|
+
|
|
52
|
+
function testStuffAndFail() {
|
|
53
|
+
return "this test failed!";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function testMoreStuffAndFail() {
|
|
57
|
+
return ["this test also failed!"];
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Test Modules
|
|
62
|
+
|
|
63
|
+
Test Modules are javascript `modules` that export two values: `tests` and `options`.
|
|
64
|
+
|
|
65
|
+
### Export Tests
|
|
66
|
+
|
|
67
|
+
Test Modules export their tests in an array called `tests`.
|
|
68
|
+
|
|
69
|
+
```TS
|
|
70
|
+
// my.tests.ts
|
|
71
|
+
|
|
72
|
+
export const tests = [
|
|
73
|
+
testStuffAndPass,
|
|
74
|
+
testMoreStuffAndPass,
|
|
75
|
+
testStuffAndFail,
|
|
76
|
+
testMoreStuffAndFail,
|
|
77
|
+
];
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Export Options
|
|
81
|
+
|
|
82
|
+
Export a parameter object named `options` to affect test behaviors in the current module:
|
|
83
|
+
|
|
84
|
+
```TS
|
|
85
|
+
// my.tests.ts
|
|
86
|
+
|
|
87
|
+
interface Options {
|
|
88
|
+
runAsynchronously?: boolean;
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
title?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
...
|
|
94
|
+
|
|
95
|
+
export const options = {
|
|
96
|
+
runAsyncronously: true,
|
|
97
|
+
timeoutMs: 3000,
|
|
98
|
+
title: import.meta.url,
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
All properties are optional and exporting an `options` pojo is not required.
|
|
103
|
+
|
|
104
|
+
Tests run sequentially unless the `runAsyncronously` property is set to `true`.
|
|
105
|
+
|
|
106
|
+
## Test Collections
|
|
107
|
+
|
|
108
|
+
A `test collection` is a javascript module that exports a list test modules called `testModules`.
|
|
109
|
+
|
|
110
|
+
```TS
|
|
111
|
+
// mod.test.ts
|
|
112
|
+
|
|
113
|
+
import * as MyTests from "./my.tests.ts";
|
|
114
|
+
|
|
115
|
+
export const testModules = [
|
|
116
|
+
MyTests
|
|
117
|
+
];
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Run Test Collections
|
|
121
|
+
|
|
122
|
+
### NodeJS
|
|
123
|
+
|
|
124
|
+
Run the following command to log the results of a test collection in nodejs.
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
npx jackrabbit ./mod.tests.ts
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
To run multiple test collections, add more filepaths as commandline arguments:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
npx jackrabbit ./mod.tests.ts ./another_mod.tests.ts
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Webdrivers
|
|
137
|
+
|
|
138
|
+
Run the following command to log the results of a test collection from a browser.
|
|
26
139
|
|
|
27
140
|
```sh
|
|
28
|
-
npx
|
|
141
|
+
npx jackrabbit_webdriver ./config.json ./mod.tests.ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
To run multiple test collections, add more filepaths as commandline arguments:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
npx jackrabbit_webdriver ./config.json ./mod.tests.ts ./another_mod.tests.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
An example `jackrabbit_webdriver` config is as follows:
|
|
151
|
+
|
|
152
|
+
```JSON
|
|
153
|
+
{
|
|
154
|
+
"host_and_port": "http://localhost:4000",
|
|
155
|
+
"run_asynchronously": false,
|
|
156
|
+
"webdrivers": [
|
|
157
|
+
{
|
|
158
|
+
"title": "Firefox",
|
|
159
|
+
"command": "geckodriver -p 4001",
|
|
160
|
+
"timeout_ms": 20000,
|
|
161
|
+
"url": "http://localhost:4001",
|
|
162
|
+
"capabilities": {
|
|
163
|
+
"alwaysMatch": {
|
|
164
|
+
"moz:firefoxOptions": {
|
|
165
|
+
"args": ["-headless"]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
29
172
|
```
|
|
30
173
|
|
|
31
174
|
## License
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
#fetchQueue = new FetchQueue();
|
|
3
|
+
#cancelled = false;
|
|
4
|
+
get cancelled() {
|
|
5
|
+
return this.#cancelled;
|
|
6
|
+
}
|
|
7
|
+
log(action) {
|
|
8
|
+
this.#fetchQueue.enqueue(function () {
|
|
9
|
+
return fetch(`/log/${action.type}`, {
|
|
10
|
+
body: JSON.stringify(action),
|
|
11
|
+
headers: new Headers([["Content-Type", "application/json"]]),
|
|
12
|
+
method: "POST",
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class FetchQueue {
|
|
18
|
+
#inbound = [];
|
|
19
|
+
#outbound = [];
|
|
20
|
+
#inRoute;
|
|
21
|
+
enqueue(queueable) {
|
|
22
|
+
this.#inbound.push(queueable);
|
|
23
|
+
if (!this.#inRoute)
|
|
24
|
+
this.#queueAtom();
|
|
25
|
+
}
|
|
26
|
+
#queueAtom() {
|
|
27
|
+
if (!this.#outbound.length) {
|
|
28
|
+
while (this.#inbound.length) {
|
|
29
|
+
let pip = this.#inbound.pop();
|
|
30
|
+
if (pip)
|
|
31
|
+
this.#outbound.push(pip);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.#inRoute = this.#outbound.pop();
|
|
35
|
+
this.#execAtom();
|
|
36
|
+
}
|
|
37
|
+
async #execAtom() {
|
|
38
|
+
if (this.#inRoute) {
|
|
39
|
+
await this.#inRoute();
|
|
40
|
+
this.#queueAtom();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Logger } from "./logger.js";
|
|
2
|
+
import { run } from "./runner.js";
|
|
3
|
+
let logger = new Logger();
|
|
4
|
+
try {
|
|
5
|
+
let jackrabbitMap = document.querySelector("script[type=jackrabbit_config]");
|
|
6
|
+
if (null === jackrabbitMap)
|
|
7
|
+
throw new Error("Failed to query jackrabbit_config script");
|
|
8
|
+
// should be it's own verification and then throw
|
|
9
|
+
let config = JSON.parse(jackrabbitMap.textContent);
|
|
10
|
+
logger.log({
|
|
11
|
+
type: "start_run",
|
|
12
|
+
time: performance.now(),
|
|
13
|
+
expected_collection_count: config?.test_collections?.length ?? 0,
|
|
14
|
+
});
|
|
15
|
+
await run(logger, config.test_collections, config.jackrabbit_url);
|
|
16
|
+
logger.log({
|
|
17
|
+
type: "end_run",
|
|
18
|
+
time: performance.now(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
logger.log({
|
|
23
|
+
type: "run_error",
|
|
24
|
+
error: e?.toString() ?? "wild horses error",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class FetchQueue {
|
|
2
|
+
#inbound = [];
|
|
3
|
+
#outbound = [];
|
|
4
|
+
#inRoute;
|
|
5
|
+
enqueue(queueable) {
|
|
6
|
+
this.#inbound.push(queueable);
|
|
7
|
+
if (!this.#inRoute)
|
|
8
|
+
this.#queueAtom();
|
|
9
|
+
}
|
|
10
|
+
#queueAtom() {
|
|
11
|
+
if (!this.#outbound.length) {
|
|
12
|
+
while (this.#inbound.length) {
|
|
13
|
+
let pip = this.#inbound.pop();
|
|
14
|
+
if (pip)
|
|
15
|
+
this.#outbound.push(pip);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
this.#inRoute = this.#outbound.pop();
|
|
19
|
+
this.#execAtom();
|
|
20
|
+
}
|
|
21
|
+
async #execAtom() {
|
|
22
|
+
if (this.#inRoute) {
|
|
23
|
+
await this.#inRoute();
|
|
24
|
+
this.#queueAtom();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { runCollection } from "jackrabbit/core/dist/mod.js";
|
|
2
|
+
export async function run(logger, files, baseUrl) {
|
|
3
|
+
for (const [collection_id, url] of files.entries()) {
|
|
4
|
+
try {
|
|
5
|
+
let filepath = URL.parse(url, baseUrl);
|
|
6
|
+
if (null === filepath)
|
|
7
|
+
throw new Error("Failed to import url: " + url);
|
|
8
|
+
let filepathStr = filepath.toString();
|
|
9
|
+
const { testModules } = await import(filepath.toString());
|
|
10
|
+
await runCollection(logger, testModules, collection_id, filepathStr);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
logger.log({
|
|
14
|
+
type: "collection_error",
|
|
15
|
+
collection_id,
|
|
16
|
+
error: e?.toString() ?? "wild horses error",
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LoggerAction,
|
|
3
|
+
LoggerInterface,
|
|
4
|
+
} from "jackrabbit/core/dist/mod.js";
|
|
5
|
+
|
|
6
|
+
interface Queueable {
|
|
7
|
+
(): Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class Logger implements LoggerInterface {
|
|
11
|
+
#fetchQueue = new FetchQueue();
|
|
12
|
+
#cancelled = false;
|
|
13
|
+
|
|
14
|
+
get cancelled() {
|
|
15
|
+
return this.#cancelled;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
log(action: LoggerAction) {
|
|
19
|
+
this.#fetchQueue.enqueue(function () {
|
|
20
|
+
return fetch(`/log/${action.type}`, {
|
|
21
|
+
body: JSON.stringify(action),
|
|
22
|
+
headers: new Headers([["Content-Type", "application/json"]]),
|
|
23
|
+
method: "POST",
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class FetchQueue {
|
|
30
|
+
#inbound: Queueable[] = [];
|
|
31
|
+
#outbound: Queueable[] = [];
|
|
32
|
+
#inRoute: Queueable | undefined;
|
|
33
|
+
|
|
34
|
+
enqueue(queueable: Queueable) {
|
|
35
|
+
this.#inbound.push(queueable);
|
|
36
|
+
if (!this.#inRoute) this.#queueAtom();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#queueAtom() {
|
|
40
|
+
if (!this.#outbound.length) {
|
|
41
|
+
while (this.#inbound.length) {
|
|
42
|
+
let pip = this.#inbound.pop();
|
|
43
|
+
if (pip) this.#outbound.push(pip);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.#inRoute = this.#outbound.pop();
|
|
48
|
+
this.#execAtom();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async #execAtom() {
|
|
52
|
+
if (this.#inRoute) {
|
|
53
|
+
await this.#inRoute();
|
|
54
|
+
this.#queueAtom();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Logger } from "./logger.js";
|
|
2
|
+
import { run } from "./runner.js";
|
|
3
|
+
|
|
4
|
+
let logger = new Logger();
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
let jackrabbitMap = document.querySelector("script[type=jackrabbit_config]");
|
|
8
|
+
if (null === jackrabbitMap)
|
|
9
|
+
throw new Error("Failed to query jackrabbit_config script");
|
|
10
|
+
|
|
11
|
+
// should be it's own verification and then throw
|
|
12
|
+
let config = JSON.parse(jackrabbitMap.textContent);
|
|
13
|
+
|
|
14
|
+
logger.log({
|
|
15
|
+
type: "start_run",
|
|
16
|
+
time: performance.now(),
|
|
17
|
+
expected_collection_count: config?.test_collections?.length ?? 0,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await run(logger, config.test_collections, config.jackrabbit_url);
|
|
21
|
+
logger.log({
|
|
22
|
+
type: "end_run",
|
|
23
|
+
time: performance.now(),
|
|
24
|
+
});
|
|
25
|
+
} catch (e: unknown) {
|
|
26
|
+
logger.log({
|
|
27
|
+
type: "run_error",
|
|
28
|
+
error: e?.toString() ?? "wild horses error",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Logger } from "./logger.js";
|
|
2
|
+
|
|
3
|
+
import { runCollection } from "jackrabbit/core/dist/mod.js";
|
|
4
|
+
|
|
5
|
+
export async function run(logger: Logger, files: string[], baseUrl: string) {
|
|
6
|
+
for (const [collection_id, url] of files.entries()) {
|
|
7
|
+
try {
|
|
8
|
+
let filepath = URL.parse(url, baseUrl);
|
|
9
|
+
if (null === filepath) throw new Error("Failed to import url: " + url);
|
|
10
|
+
|
|
11
|
+
let filepathStr = filepath.toString();
|
|
12
|
+
const { testModules } = await import(filepath.toString());
|
|
13
|
+
await runCollection(logger, testModules, collection_id, filepathStr);
|
|
14
|
+
} catch (e: unknown) {
|
|
15
|
+
logger.log({
|
|
16
|
+
type: "collection_error",
|
|
17
|
+
collection_id,
|
|
18
|
+
error: e?.toString() ?? "wild horses error",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/logger.ts","./src/mod.ts","./src/runner.ts"],"version":"5.9.3"}
|
package/browsers.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host_and_port": "http://localhost:4000",
|
|
3
|
+
"run_asynchronously": false,
|
|
4
|
+
"webdrivers": [
|
|
5
|
+
{
|
|
6
|
+
"command": "safaridriver -p 4001",
|
|
7
|
+
"title": "Safari",
|
|
8
|
+
"timeout_ms": 20000,
|
|
9
|
+
"url": "http://localhost:4001"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"command": "geckodriver -p 4001",
|
|
13
|
+
"title": "Firefox",
|
|
14
|
+
"timeout_ms": 20000,
|
|
15
|
+
"url": "http://localhost:4001",
|
|
16
|
+
"capabilities": {
|
|
17
|
+
"alwaysMatch": {
|
|
18
|
+
"moz:firefoxOptions": {
|
|
19
|
+
"args": ["-headless"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"command": "/Users/taylor/workspace/chromedriver-mac-arm64/chromedriver --port=4001",
|
|
26
|
+
"title": "Chrome",
|
|
27
|
+
"timeout_ms": 20000,
|
|
28
|
+
"url": "http://localhost:4001",
|
|
29
|
+
"capabilities": {
|
|
30
|
+
"alwaysMatch": {
|
|
31
|
+
"goog:chromeOptions": {
|
|
32
|
+
"args": ["--headless"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|