@w-lfpup/jackrabbit 0.2.0 → 0.3.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/workflows/browsers.json +55 -0
- package/.github/workflows/browsers.macos.json +51 -0
- package/.github/workflows/browsers.windows.json +19 -0
- package/.github/workflows/tests.yml +13 -0
- package/README.md +41 -1
- package/browser/dist/logger.js +43 -0
- package/browser/dist/mod.js +25 -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 +61 -27
- 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 +72 -28
- 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 +164 -0
- package/nodejs/dist/mod.js +33 -0
- package/nodejs/dist/results.js +145 -0
- package/nodejs/dist/results_str.js +147 -0
- package/nodejs/dist/runner.js +17 -0
- package/nodejs/src/logger.ts +200 -0
- package/nodejs/src/mod.ts +39 -0
- package/nodejs/src/results.ts +239 -0
- package/{nodejs_cli → nodejs}/tsconfig.json +2 -1
- package/nodejs/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -4
- package/tests/dist/mod.d.ts +14 -3
- package/tests/dist/mod.js +33 -15
- package/tests/dist/test_error.test.d.ts +9 -0
- package/tests/dist/test_error.test.js +25 -0
- package/tests/dist/test_errors.test.d.ts +9 -0
- package/tests/dist/test_errors.test.js +27 -0
- package/tests/dist/test_fail.test.js +0 -2
- package/tests/dist/test_logger.d.ts +3 -2
- package/tests/dist/test_logger.js +5 -1
- package/tests/dist/test_pass.test.js +0 -2
- 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 +3 -2
- package/webdriver/dist/config.js +56 -0
- package/webdriver/dist/eventbus.js +18 -0
- package/webdriver/dist/listeners.js +21 -0
- package/webdriver/dist/logger.js +200 -0
- package/webdriver/dist/mod.js +35 -0
- package/webdriver/dist/results.js +190 -0
- package/webdriver/dist/results_str.js +167 -0
- package/webdriver/dist/routes.js +162 -0
- package/webdriver/dist/routes2.js +163 -0
- package/webdriver/dist/test_hangar.js +20 -0
- package/webdriver/dist/webdriver.js +272 -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 +45 -0
- package/webdriver/src/results.ts +311 -0
- package/webdriver/src/routes.ts +198 -0
- package/webdriver/src/test_hangar.ts +25 -0
- package/webdriver/src/webdriver.ts +373 -0
- package/{cli → webdriver}/tsconfig.json +1 -0
- package/webdriver/tsconfig.tsbuildinfo +1 -0
- 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/cli_types.js +0 -1
- package/cli/dist/config.d.ts +0 -5
- package/cli/dist/config.js +0 -6
- 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 -9
- 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/{nodejs_cli → nodejs}/package.json +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"host_and_port": "http://127.0.0.1:4000",
|
|
3
|
+
"runAsynchronusly": false,
|
|
4
|
+
"webdrivers": [
|
|
5
|
+
{
|
|
6
|
+
"title": "Firefox",
|
|
7
|
+
"command": "$GECKOWEBDRIVER/geckodriver -p 4001",
|
|
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
|
+
"title": "Chrome",
|
|
20
|
+
"command": "$CHROMEWEBDRIVER/chromedriver --port=4005",
|
|
21
|
+
"timeout_ms": 30000,
|
|
22
|
+
"url": "http://localhost:4005",
|
|
23
|
+
"capabilities": {
|
|
24
|
+
"alwaysMatch": {
|
|
25
|
+
"goog:chromeOptions": {
|
|
26
|
+
"args": [
|
|
27
|
+
"--headless",
|
|
28
|
+
"--disbale-gpu",
|
|
29
|
+
"--disable-dev-shm-usage",
|
|
30
|
+
"--start-maximized"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"title": "Edge",
|
|
38
|
+
"command": "$EDGEWEBDRIVER/msedgedriver --port=4010",
|
|
39
|
+
"timeout_ms": 30000,
|
|
40
|
+
"url": "http://localhost:4010",
|
|
41
|
+
"capabilities": {
|
|
42
|
+
"alwaysMatch": {
|
|
43
|
+
"ms:edgeOptions": {
|
|
44
|
+
"args": [
|
|
45
|
+
"--headless",
|
|
46
|
+
"--disbale-gpu",
|
|
47
|
+
"--disable-dev-shm-usage",
|
|
48
|
+
"--start-maximized"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -16,3 +16,16 @@ jobs:
|
|
|
16
16
|
run: npm ci
|
|
17
17
|
- name: Test
|
|
18
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
|
package/README.md
CHANGED
|
@@ -119,7 +119,9 @@ export const testModules = [
|
|
|
119
119
|
|
|
120
120
|
## Run Test Collections
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
### NodeJS
|
|
123
|
+
|
|
124
|
+
Run the following command to log the results of a test collection in nodejs.
|
|
123
125
|
|
|
124
126
|
```sh
|
|
125
127
|
npx jackrabbit ./mod.tests.ts
|
|
@@ -131,6 +133,44 @@ To run multiple test collections, add more filepaths as commandline arguments:
|
|
|
131
133
|
npx jackrabbit ./mod.tests.ts ./another_mod.tests.ts
|
|
132
134
|
```
|
|
133
135
|
|
|
136
|
+
### Webdrivers
|
|
137
|
+
|
|
138
|
+
Run the following command to log the results of a test collection from a browser.
|
|
139
|
+
|
|
140
|
+
```sh
|
|
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
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
134
174
|
## License
|
|
135
175
|
|
|
136
176
|
`Jackrabbit-js` is released under the BSD 3-Clause 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,25 @@
|
|
|
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
|
+
let config = JSON.parse(jackrabbitMap.textContent);
|
|
9
|
+
logger.log({
|
|
10
|
+
type: "start_run",
|
|
11
|
+
time: performance.now(),
|
|
12
|
+
expected_collection_count: config?.test_collections?.length ?? 0,
|
|
13
|
+
});
|
|
14
|
+
await run(logger, config.test_collections, config.jackrabbit_url);
|
|
15
|
+
logger.log({
|
|
16
|
+
type: "end_run",
|
|
17
|
+
time: performance.now(),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
logger.log({
|
|
22
|
+
type: "run_error",
|
|
23
|
+
error: e?.toString() ?? "wild horses error",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,56 +1,90 @@
|
|
|
1
1
|
interface Stringable {
|
|
2
2
|
toString: Object["toString"];
|
|
3
3
|
}
|
|
4
|
-
export type Assertions = Stringable | Stringable[] | undefined;
|
|
4
|
+
export type Assertions = Stringable | Stringable[] | undefined | null;
|
|
5
5
|
type SyncTest = () => Assertions;
|
|
6
6
|
type AsyncTest = () => Promise<Assertions>;
|
|
7
7
|
export type Test = SyncTest | AsyncTest;
|
|
8
|
-
export interface
|
|
8
|
+
export interface TestOptions {
|
|
9
9
|
runAsynchronously?: boolean;
|
|
10
10
|
timeoutMs?: number;
|
|
11
11
|
title?: string;
|
|
12
12
|
}
|
|
13
13
|
export interface TestModule {
|
|
14
|
+
options?: TestOptions;
|
|
14
15
|
tests: Test[];
|
|
15
|
-
options: Options;
|
|
16
16
|
}
|
|
17
|
-
interface StartRun {
|
|
18
|
-
|
|
17
|
+
export interface StartRun {
|
|
18
|
+
expected_collection_count: number;
|
|
19
19
|
time: number;
|
|
20
|
+
type: "start_run";
|
|
20
21
|
}
|
|
21
|
-
interface EndRun {
|
|
22
|
-
type: "end_run";
|
|
22
|
+
export interface EndRun {
|
|
23
23
|
time: number;
|
|
24
|
+
type: "end_run";
|
|
24
25
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
export interface RunError {
|
|
27
|
+
error: string;
|
|
28
|
+
type: "run_error";
|
|
29
|
+
}
|
|
30
|
+
export interface StartTestCollection {
|
|
31
|
+
collection_id: number;
|
|
32
|
+
collection_url: string;
|
|
33
|
+
expected_module_count: number;
|
|
34
|
+
type: "start_collection";
|
|
28
35
|
}
|
|
29
|
-
interface
|
|
36
|
+
export interface EndTestCollection {
|
|
37
|
+
collection_id: number;
|
|
38
|
+
type: "end_collection";
|
|
39
|
+
}
|
|
40
|
+
export interface TestCollectionError {
|
|
41
|
+
collection_id: number;
|
|
42
|
+
error: string;
|
|
43
|
+
type: "collection_error";
|
|
44
|
+
}
|
|
45
|
+
export interface StartModule {
|
|
46
|
+
collection_id: number;
|
|
47
|
+
expected_test_count: number;
|
|
48
|
+
module_id: number;
|
|
49
|
+
module_name: string;
|
|
30
50
|
type: "start_module";
|
|
31
|
-
moduleId: number;
|
|
32
51
|
}
|
|
33
|
-
interface EndModule {
|
|
52
|
+
export interface EndModule {
|
|
53
|
+
collection_id: number;
|
|
54
|
+
module_id: number;
|
|
34
55
|
type: "end_module";
|
|
35
|
-
moduleId: number;
|
|
36
56
|
}
|
|
37
|
-
interface
|
|
57
|
+
export interface ModuleError {
|
|
58
|
+
collection_id: number;
|
|
59
|
+
error: string;
|
|
60
|
+
module_id: number;
|
|
61
|
+
type: "module_error";
|
|
62
|
+
}
|
|
63
|
+
export interface StartTest {
|
|
64
|
+
collection_id: number;
|
|
65
|
+
module_id: number;
|
|
66
|
+
test_id: number;
|
|
67
|
+
test_name: string;
|
|
38
68
|
type: "start_test";
|
|
39
|
-
testId: number;
|
|
40
|
-
moduleId: number;
|
|
41
69
|
}
|
|
42
|
-
interface EndTest {
|
|
43
|
-
type: "end_test";
|
|
44
|
-
testId: number;
|
|
45
|
-
moduleId: number;
|
|
46
|
-
startTime: number;
|
|
47
|
-
endTime: number;
|
|
70
|
+
export interface EndTest {
|
|
48
71
|
assertions: Assertions;
|
|
72
|
+
collection_id: number;
|
|
73
|
+
module_id: number;
|
|
74
|
+
test_id: number;
|
|
75
|
+
start_time: number;
|
|
76
|
+
end_time: number;
|
|
77
|
+
type: "end_test";
|
|
78
|
+
}
|
|
79
|
+
export interface TestError {
|
|
80
|
+
collection_id: number;
|
|
81
|
+
error: string;
|
|
82
|
+
module_id: number;
|
|
83
|
+
test_id: number;
|
|
84
|
+
type: "test_error";
|
|
49
85
|
}
|
|
50
|
-
export type LoggerAction = StartRun | EndRun |
|
|
86
|
+
export type LoggerAction = StartRun | EndRun | RunError | StartTestCollection | EndTestCollection | TestCollectionError | StartModule | ModuleError | EndModule | StartTest | EndTest | TestError;
|
|
51
87
|
export interface LoggerInterface {
|
|
52
|
-
|
|
53
|
-
readonly cancelled: boolean;
|
|
54
|
-
log(testModules: TestModule[], action: LoggerAction): void;
|
|
88
|
+
log(action: LoggerAction): void;
|
|
55
89
|
}
|
|
56
90
|
export {};
|
package/core/dist/mod.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export {
|
|
1
|
+
export type * from "./jackrabbit_types.ts";
|
|
2
|
+
export { runCollection, sleep } from "./run_steps.js";
|
package/core/dist/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { runCollection, sleep } from "./run_steps.js";
|
package/core/dist/run_steps.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LoggerInterface, TestModule } from "./jackrabbit_types.ts";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function sleep(time: number): Promise<void>;
|
|
3
|
+
export declare function runCollection(logger: LoggerInterface, testModules: TestModule[], collection_id: number, collection_url: string): Promise<void>;
|