qase-javascript-commons 2.0.0-beta.0 → 2.0.0-beta.10
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/README.md +74 -97
- package/changelog.md +159 -0
- package/dist/config/config-loader-interface.d.ts +4 -0
- package/dist/config/config-loader-interface.js +2 -0
- package/dist/config/config-loader.d.ts +10 -0
- package/dist/config/config-loader.js +58 -0
- package/dist/config/config-type.d.ts +2 -0
- package/dist/config/config-type.js +2 -0
- package/dist/config/config-validation-schema.d.ts +6 -0
- package/dist/config/config-validation-schema.js +163 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +7 -0
- package/dist/env/env-enum.d.ts +54 -0
- package/dist/env/env-enum.js +64 -0
- package/dist/env/env-to-config.d.ts +7 -0
- package/dist/env/env-to-config.js +46 -0
- package/dist/env/env-type.d.ts +24 -0
- package/dist/env/env-type.js +3 -0
- package/dist/env/env-validation-schema.d.ts +6 -0
- package/dist/env/env-validation-schema.js +93 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.js +13 -0
- package/dist/formatter/formatter-interface.d.ts +3 -0
- package/dist/formatter/formatter-interface.js +2 -0
- package/dist/formatter/index.d.ts +3 -0
- package/dist/formatter/index.js +7 -0
- package/dist/formatter/json-formatter.d.ts +13 -0
- package/dist/formatter/json-formatter.js +27 -0
- package/dist/formatter/jsonp-formatter.d.ts +13 -0
- package/dist/formatter/jsonp-formatter.js +28 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -0
- package/dist/models/attachment.d.ts +9 -0
- package/dist/models/attachment.js +2 -0
- package/dist/models/execution-sum.d.ts +6 -0
- package/dist/models/execution-sum.js +2 -0
- package/dist/models/host-data.d.ts +11 -0
- package/dist/models/host-data.js +2 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +9 -0
- package/dist/models/report.d.ts +14 -0
- package/dist/models/report.js +2 -0
- package/dist/models/short-result.d.ts +7 -0
- package/dist/models/short-result.js +2 -0
- package/dist/models/stats.d.ts +8 -0
- package/dist/models/stats.js +2 -0
- package/dist/models/step-data.d.ts +9 -0
- package/dist/models/step-data.js +2 -0
- package/dist/models/step-execution.d.ts +11 -0
- package/dist/models/step-execution.js +9 -0
- package/dist/models/test-execution.d.ts +19 -0
- package/dist/models/test-execution.js +15 -0
- package/dist/models/test-result.d.ts +29 -0
- package/dist/models/test-result.js +2 -0
- package/dist/models/test-step.d.ts +16 -0
- package/dist/models/test-step.js +8 -0
- package/dist/options/composeOptions.d.ts +9 -0
- package/dist/options/composeOptions.js +12 -0
- package/dist/options/index.d.ts +3 -0
- package/dist/options/index.js +7 -0
- package/dist/options/mode-enum.d.ts +8 -0
- package/dist/options/mode-enum.js +12 -0
- package/dist/options/options-type.d.ts +33 -0
- package/dist/options/options-type.js +3 -0
- package/dist/qase.d.ts +97 -0
- package/dist/qase.js +301 -0
- package/dist/reporters/abstract-reporter.d.ts +51 -0
- package/dist/reporters/abstract-reporter.js +59 -0
- package/dist/reporters/index.d.ts +3 -0
- package/dist/reporters/index.js +9 -0
- package/dist/reporters/report-reporter.d.ts +46 -0
- package/dist/reporters/report-reporter.js +185 -0
- package/dist/reporters/testops-reporter.d.ts +179 -0
- package/dist/reporters/testops-reporter.js +398 -0
- package/dist/utils/custom-boundary.d.ts +26 -0
- package/dist/utils/custom-boundary.js +30 -0
- package/dist/utils/disabled-exception.d.ts +6 -0
- package/dist/utils/disabled-exception.js +10 -0
- package/dist/utils/get-package-version.d.ts +5 -0
- package/dist/utils/get-package-version.js +25 -0
- package/dist/utils/is-axios-error.d.ts +6 -0
- package/dist/utils/is-axios-error.js +11 -0
- package/dist/utils/logger.d.ts +29 -0
- package/dist/utils/logger.js +121 -0
- package/dist/utils/mimeTypes.d.ts +5 -0
- package/dist/utils/mimeTypes.js +41 -0
- package/dist/utils/qase-error.d.ts +18 -0
- package/dist/utils/qase-error.js +15 -0
- package/dist/utils/validate-json.d.ts +20 -0
- package/dist/utils/validate-json.js +40 -0
- package/dist/writer/driver-enum.d.ts +13 -0
- package/dist/writer/driver-enum.js +18 -0
- package/dist/writer/fs-writer.d.ts +40 -0
- package/dist/writer/fs-writer.js +126 -0
- package/dist/writer/index.d.ts +3 -0
- package/dist/writer/index.js +8 -0
- package/dist/writer/writer-interface.d.ts +7 -0
- package/dist/writer/writer-interface.js +2 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,102 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
# Qase JavaScript Commons
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
$ npm install --save qase-core-reporter
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
> Create a new Qase JS reporter in minutes by leveraging this core reporter.
|
|
10
|
-
> Use Qase core reporter with test framework custom reporter hooks
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
import {
|
|
14
|
-
QaseCoreReporter,
|
|
15
|
-
QaseOptions,
|
|
16
|
-
QaseCoreReporterOptions,
|
|
17
|
-
TestResult
|
|
18
|
-
} from "qase-core-reporter";
|
|
3
|
+
This package contains common classes and functions for working with Qase TMS API.
|
|
19
4
|
|
|
20
|
-
|
|
21
|
-
// expected options, provided by reporter user
|
|
22
|
-
apiToken: 'lknkldnfknobek'
|
|
23
|
-
projectCode: 'DH'
|
|
24
|
-
};
|
|
5
|
+
## Installation
|
|
25
6
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
frameworkName: 'vitest',
|
|
29
|
-
reporterName: 'vitest-qase-reporter'
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Initialize Core reporter with expected params
|
|
33
|
-
const reporter = new QaseCoreReporter(reporterOptions, qaseCoreReporterOptions);
|
|
34
|
-
|
|
35
|
-
// On start hook
|
|
36
|
-
reporter.start();
|
|
37
|
-
|
|
38
|
-
// On test results
|
|
39
|
-
reporter.addTestResult(test: TestResult, status, attachments);
|
|
40
|
-
|
|
41
|
-
// On end/complete hook
|
|
42
|
-
reporter.end({ spawn: false }); // spawn true will finish reporting in a child process
|
|
7
|
+
```bash
|
|
8
|
+
npm install qase-javascript-commons@beta
|
|
43
9
|
```
|
|
44
10
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Qase JS Reporters can be configured in multiple ways:
|
|
14
|
+
|
|
15
|
+
- using a config file `qase.config.json`
|
|
16
|
+
- using environment variables
|
|
17
|
+
|
|
18
|
+
All configuration options are listed in the table below:
|
|
19
|
+
|
|
20
|
+
| Description | Config file | Environment variable | Default value | Required | Possible values |
|
|
21
|
+
|----------------------------------------------------------------------------------------------------------------------------|----------------------------|---------------------------------|-----------------------------------------|----------|----------------------------|
|
|
22
|
+
| **Common** | | | | | |
|
|
23
|
+
| Mode of reporter | `mode` | `QASE_MODE` | `testops` | No | `testops`, `report`, `off` |
|
|
24
|
+
| Fallback mode of reporter | `fallback` | `QASE_FALLBACK` | `off` | No | `testops`, `report`, `off` |
|
|
25
|
+
| Environment | `environment` | `QASE_ENVIRONMENT` | `local` | No | Any string |
|
|
26
|
+
| Enable debug logs | `debug` | `QASE_DEBUG` | `False` | No | `True`, `False` |
|
|
27
|
+
| Enable capture logs from `stdout` and `stderr` | `testops.defect` | `QASE_CAPTURE_LOGS` | `False` | No | `True`, `False` |
|
|
28
|
+
| **Qase Report configuration** | | | | | |
|
|
29
|
+
| Driver used for report mode | `report.driver` | `QASE_REPORT_DRIVER` | `local` | No | `local` |
|
|
30
|
+
| Path to save the report | `report.connection.path` | `QASE_REPORT_CONNECTION_PATH` | `./build/qase-report` | | |
|
|
31
|
+
| Local report format | `report.connection.format` | `QASE_REPORT_CONNECTION_FORMAT` | `json` | | `json`, `jsonp` |
|
|
32
|
+
| **Qase TestOps configuration** | | | | | |
|
|
33
|
+
| Token for [API access](https://developers.qase.io/#authentication) | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | | Yes | Any string |
|
|
34
|
+
| Qase API host | `testops.api.host` | `QASE_TESTOPS_API_HOST` | `qase.io` | No | Any string |
|
|
35
|
+
| Code of your project, which you can take from the URL: `https://app.qase.io/project/DEMOTR` - `DEMOTR` is the project code | `testops.project` | `QASE_TESTOPS_PROJECT` | | Yes | Any string |
|
|
36
|
+
| Qase test run ID | `testops.run.id` | `QASE_TESTOPS_RUN_ID` | | No | Any integer |
|
|
37
|
+
| Qase test run title | `testops.run.title` | `QASE_TESTOPS_RUN_TITLE` | `Automated run <Current date and time>` | No | Any string |
|
|
38
|
+
| Qase test run description | `testops.run.description` | `QASE_TESTOPS_RUN_DESCRIPTION` | `<Framework name> automated run` | No | Any string |
|
|
39
|
+
| Qase test run complete | `testops.run.complete` | `QASE_TESTOPS_RUN_COMPLETE` | `True` | | `True`, `False` |
|
|
40
|
+
| Qase test plan ID | `testops.plan.id` | `QASE_TESTOPS_PLAN_ID` | | No | Any integer |
|
|
41
|
+
| Size of batch for sending test results | `testops.batch.size` | `QASE_TESTOPS_BATCH_SIZE` | `200` | No | Any integer |
|
|
42
|
+
| Enable defects for failed test cases | `testops.defect` | `QASE_TESTOPS_DEFECT` | `False` | No | `True`, `False` |
|
|
43
|
+
|
|
44
|
+
### Example `qase.config.json` config:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mode": "testops",
|
|
49
|
+
"fallback": "report",
|
|
50
|
+
"debug": false,
|
|
51
|
+
"environment": "local",
|
|
52
|
+
"captureLogs": false,
|
|
53
|
+
"report": {
|
|
54
|
+
"driver": "local",
|
|
55
|
+
"connection": {
|
|
56
|
+
"local": {
|
|
57
|
+
"path": "./build/qase-report",
|
|
58
|
+
"format": "json"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"testops": {
|
|
63
|
+
"api": {
|
|
64
|
+
"token": "<token>",
|
|
65
|
+
"host": "qase.io"
|
|
66
|
+
},
|
|
67
|
+
"run": {
|
|
68
|
+
"title": "Regress run",
|
|
69
|
+
"description": "Regress run description",
|
|
70
|
+
"complete": true
|
|
71
|
+
},
|
|
72
|
+
"defect": false,
|
|
73
|
+
"project": "<project_code>",
|
|
74
|
+
"batch": {
|
|
75
|
+
"size": 100
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
package/changelog.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# qase-javascript-commons@2.0.0-beta.10
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Fixed an issue when the results published before the test run creation.
|
|
6
|
+
|
|
7
|
+
# qase-javascript-commons@2.0.0-beta.9
|
|
8
|
+
|
|
9
|
+
## What's new
|
|
10
|
+
|
|
11
|
+
Improved debug logging for better testing and reporting errors.
|
|
12
|
+
|
|
13
|
+
- Separate `logger` class for use in reporters, supporting logging to console and files.
|
|
14
|
+
- Extra debug logs in both reporter modes: TestOps and Local.
|
|
15
|
+
|
|
16
|
+
Fixed an issue with duplicate test runs created when the testing framework
|
|
17
|
+
(such as Cypress) uses more than one instance of the Qase reporter.
|
|
18
|
+
Now reporter handles Qase test runs in the following way:
|
|
19
|
+
|
|
20
|
+
1. The first instance of the reporter creates a Qase test run and stores the run ID
|
|
21
|
+
in the ENV variable `QASE_TESTOPS_RUN_ID`.
|
|
22
|
+
2. Other instances of the reporter read this variable and report test results
|
|
23
|
+
to the existing test run.
|
|
24
|
+
|
|
25
|
+
Nothing has changed in cases when there is a single instance of a reporter or
|
|
26
|
+
when it is using a test run, created with other tools, such as with an API request
|
|
27
|
+
or manually in the Qase app.
|
|
28
|
+
|
|
29
|
+
# qase-javascript-commons@2.0.0-beta.8
|
|
30
|
+
|
|
31
|
+
## What's new
|
|
32
|
+
|
|
33
|
+
Renamed the `QASE_TESTOPS_CHUNK` environment variable to `QASE_TESTOPS_BATCH_SIZE`.
|
|
34
|
+
Renamed the `chunk` field in the reporter's configuration to `batch.size`.
|
|
35
|
+
|
|
36
|
+
```diff
|
|
37
|
+
{
|
|
38
|
+
...
|
|
39
|
+
"testops": {
|
|
40
|
+
- "chunk": 10
|
|
41
|
+
+ "batch": {
|
|
42
|
+
+ "size": 10
|
|
43
|
+
+ }
|
|
44
|
+
...
|
|
45
|
+
},
|
|
46
|
+
...
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
# qase-javascript-commons@2.0.0-beta.7
|
|
51
|
+
|
|
52
|
+
## What's new
|
|
53
|
+
|
|
54
|
+
TestOps reporter supports uploading test result in real-time.
|
|
55
|
+
It can be useful for long-running tests, where you want to see the results as soon as they are available.
|
|
56
|
+
You can use chunk size to control the size of the data sent to the Qase.
|
|
57
|
+
|
|
58
|
+
To enable real-time reporting, set an environment variable before running the tests or use the reporter's configuration:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
QASE_TESTOPS_CHUNK=10
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```diff
|
|
65
|
+
{
|
|
66
|
+
...
|
|
67
|
+
"testops": {
|
|
68
|
+
+ "chunk": 10
|
|
69
|
+
...
|
|
70
|
+
},
|
|
71
|
+
...
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
where `10` is the size of the chunk in test result's count.
|
|
76
|
+
|
|
77
|
+
# qase-javascript-commons@2.0.0-beta.6
|
|
78
|
+
|
|
79
|
+
## What's new
|
|
80
|
+
|
|
81
|
+
### Select the API version to use for reporting
|
|
82
|
+
|
|
83
|
+
Qase TestOps API has two endpoints for reporting test results:
|
|
84
|
+
|
|
85
|
+
- Version 1, stable and used my most test reporters.
|
|
86
|
+
https://developers.qase.io/reference/create-result-bulk
|
|
87
|
+
- Version 2, currently in beta access, and currently supported only
|
|
88
|
+
in the `playwright-qase-reporter`.
|
|
89
|
+
https://developers.qase.io/v2.0/reference/create-results-v2
|
|
90
|
+
|
|
91
|
+
This commit introduces a way to select the API version to use.
|
|
92
|
+
It enables using all new features of v2 JS reporters with the stable v1 API,
|
|
93
|
+
and elso experimenting with the new v2 API.
|
|
94
|
+
|
|
95
|
+
**Warning**: v2 API is still in beta.
|
|
96
|
+
If you want to try the v2 JS reporters, you don't have to enable the new API.
|
|
97
|
+
|
|
98
|
+
To enable using API v2, set an environment variable before running the tests:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
QASE_TESTOPS_API_V2=true
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Support adding test suite description to a test report.
|
|
105
|
+
|
|
106
|
+
Test reporters can now test suite description to test results.
|
|
107
|
+
Such description can be collected from test's location and attributes
|
|
108
|
+
or explicitly declared in the test.
|
|
109
|
+
|
|
110
|
+
Add new data models:
|
|
111
|
+
- Relation
|
|
112
|
+
- Suite
|
|
113
|
+
- SuiteData
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# qase-javascript-commons@2.0.0-beta.5
|
|
117
|
+
|
|
118
|
+
## What's new
|
|
119
|
+
|
|
120
|
+
* Update the config of reporters. Added `captureLogs` field. If it is set to `true`, the reporter will capture logs from the test framework.
|
|
121
|
+
* Added `getMimeType` function to the commons package. It returns the MIME type of the file by its extension.
|
|
122
|
+
|
|
123
|
+
# qase-javascript-commons@2.0.0-beta.4
|
|
124
|
+
|
|
125
|
+
## What's new
|
|
126
|
+
|
|
127
|
+
* Added support for uploading attachments from strings and buffers in the testops reporter.
|
|
128
|
+
* Changed data type of `content` in the attachment data from `any` to `string | Buffer`.
|
|
129
|
+
|
|
130
|
+
# qase-javascript-commons@2.0.0-beta.3
|
|
131
|
+
|
|
132
|
+
## What's new
|
|
133
|
+
|
|
134
|
+
* Changed data type of `fields` and `parameters` in the test result data
|
|
135
|
+
from `Map<string, string>` to `Record<string, string>`.
|
|
136
|
+
|
|
137
|
+
# qase-javascript-commons@2.0.0-beta.2
|
|
138
|
+
|
|
139
|
+
## Overview
|
|
140
|
+
|
|
141
|
+
Package `qase-javascript-commons` contains common functions, used by all Qase JavaScript reporters.
|
|
142
|
+
|
|
143
|
+
This is a beta channel release.
|
|
144
|
+
Don't install this package explicitly.
|
|
145
|
+
Instead, install the test reporter for your framework, for example:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm install playwright-qase-reporter@beta
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## What's new
|
|
152
|
+
|
|
153
|
+
* Set a fallback reporter when the primary reporter can't be used,
|
|
154
|
+
such as when the `testops` reporter can't authenticate with the Qase API.
|
|
155
|
+
* Rename some environment variables to keep naming consistent between reporters in all languages.
|
|
156
|
+
* Add several environment variables for new config options.
|
|
157
|
+
* Write outputs in JSONP format, which can be used with
|
|
158
|
+
[Qase Report](https://github.com/qase-tms/qase-report).
|
|
159
|
+
* Logic for handling test with multiple case IDs moved to the commons package.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONSchemaType } from 'ajv';
|
|
2
|
+
import { ConfigLoaderInterface } from './config-loader-interface';
|
|
3
|
+
import { ConfigType } from './config-type';
|
|
4
|
+
export declare class ConfigLoader<T extends Partial<ConfigType> & Record<string, unknown>> implements ConfigLoaderInterface<T> {
|
|
5
|
+
private paths;
|
|
6
|
+
private validationSchema;
|
|
7
|
+
constructor(validationSchema?: JSONSchemaType<T>, paths?: string[]);
|
|
8
|
+
private read;
|
|
9
|
+
load(): (T & ConfigType) | null;
|
|
10
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfigLoader = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
10
|
+
const qase_error_1 = require("../utils/qase-error");
|
|
11
|
+
const validate_json_1 = require("../utils/validate-json");
|
|
12
|
+
const config_validation_schema_1 = require("./config-validation-schema");
|
|
13
|
+
class ConfigLoader {
|
|
14
|
+
constructor(validationSchema, paths = ['qase.config.json', '.qaserc']) {
|
|
15
|
+
this.paths = paths;
|
|
16
|
+
this.validationSchema = (0, lodash_merge_1.default)({}, config_validation_schema_1.configValidationSchema, validationSchema);
|
|
17
|
+
}
|
|
18
|
+
read() {
|
|
19
|
+
for (const path of this.paths) {
|
|
20
|
+
const filePath = (0, path_1.join)(process.cwd(), path);
|
|
21
|
+
try {
|
|
22
|
+
return (0, fs_1.readFileSync)(filePath, 'utf8');
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const isNotFound = error instanceof Error &&
|
|
26
|
+
'code' in error &&
|
|
27
|
+
(error.code === 'ENOENT' || error.code === 'EISDIR');
|
|
28
|
+
if (!isNotFound) {
|
|
29
|
+
throw new qase_error_1.QaseError('Cannot read config file', { cause: error });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
load() {
|
|
36
|
+
try {
|
|
37
|
+
const data = this.read();
|
|
38
|
+
if (data) {
|
|
39
|
+
const json = JSON.parse(data);
|
|
40
|
+
(0, validate_json_1.validateJson)(this.validationSchema, json);
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof validate_json_1.JsonValidationError) {
|
|
46
|
+
const [validationError] = error.validationErrors;
|
|
47
|
+
const { instancePath = '', message = '' } = validationError ?? {};
|
|
48
|
+
const configPath = instancePath
|
|
49
|
+
? `\`${instancePath.substring(1).replace('/', '.')}\``
|
|
50
|
+
: 'it';
|
|
51
|
+
throw new Error(`Invalid config: "${configPath}" ${message}`);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ConfigLoader = ConfigLoader;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configValidationSchema = void 0;
|
|
4
|
+
const options_1 = require("../options");
|
|
5
|
+
const writer_1 = require("../writer");
|
|
6
|
+
/**
|
|
7
|
+
* @type {JSONSchemaType<ConfigType>}
|
|
8
|
+
*/
|
|
9
|
+
exports.configValidationSchema = {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
mode: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
enum: [options_1.ModeEnum.report, options_1.ModeEnum.testops, options_1.ModeEnum.off],
|
|
15
|
+
nullable: true,
|
|
16
|
+
},
|
|
17
|
+
fallback: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
enum: [options_1.ModeEnum.report, options_1.ModeEnum.testops, options_1.ModeEnum.off],
|
|
20
|
+
nullable: true,
|
|
21
|
+
},
|
|
22
|
+
debug: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
nullable: true,
|
|
25
|
+
},
|
|
26
|
+
environment: {
|
|
27
|
+
type: ['string', 'number'],
|
|
28
|
+
nullable: true,
|
|
29
|
+
},
|
|
30
|
+
captureLogs: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
nullable: true,
|
|
33
|
+
},
|
|
34
|
+
testops: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
nullable: true,
|
|
37
|
+
properties: {
|
|
38
|
+
api: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
nullable: true,
|
|
41
|
+
properties: {
|
|
42
|
+
token: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
nullable: true,
|
|
45
|
+
},
|
|
46
|
+
baseUrl: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
nullable: true,
|
|
49
|
+
},
|
|
50
|
+
headers: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
nullable: true,
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
patternProperties: {
|
|
55
|
+
'^.*$': {
|
|
56
|
+
type: 'string',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
retries: {
|
|
61
|
+
type: 'number',
|
|
62
|
+
nullable: true,
|
|
63
|
+
},
|
|
64
|
+
retryDelay: {
|
|
65
|
+
type: 'number',
|
|
66
|
+
nullable: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
project: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
nullable: true,
|
|
73
|
+
},
|
|
74
|
+
uploadAttachments: {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
nullable: true,
|
|
77
|
+
},
|
|
78
|
+
run: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
nullable: true,
|
|
81
|
+
properties: {
|
|
82
|
+
id: {
|
|
83
|
+
type: 'number',
|
|
84
|
+
nullable: true,
|
|
85
|
+
},
|
|
86
|
+
title: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
nullable: true,
|
|
89
|
+
},
|
|
90
|
+
description: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
nullable: true,
|
|
93
|
+
},
|
|
94
|
+
complete: {
|
|
95
|
+
type: 'boolean',
|
|
96
|
+
nullable: true,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
plan: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
nullable: true,
|
|
103
|
+
properties: {
|
|
104
|
+
id: {
|
|
105
|
+
type: 'number',
|
|
106
|
+
nullable: true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
batch: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
nullable: true,
|
|
113
|
+
properties: {
|
|
114
|
+
size: {
|
|
115
|
+
type: 'number',
|
|
116
|
+
nullable: true,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
defect: {
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
nullable: true,
|
|
123
|
+
},
|
|
124
|
+
useV2: {
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
nullable: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
report: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
nullable: true,
|
|
133
|
+
properties: {
|
|
134
|
+
driver: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
enum: [writer_1.DriverEnum.local],
|
|
137
|
+
nullable: true,
|
|
138
|
+
},
|
|
139
|
+
connections: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
nullable: true,
|
|
142
|
+
properties: {
|
|
143
|
+
[writer_1.DriverEnum.local]: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
nullable: true,
|
|
146
|
+
properties: {
|
|
147
|
+
path: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
nullable: true,
|
|
150
|
+
},
|
|
151
|
+
format: {
|
|
152
|
+
type: 'string',
|
|
153
|
+
enum: [writer_1.FormatEnum.json, writer_1.FormatEnum.jsonp],
|
|
154
|
+
nullable: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigLoader = exports.configValidationSchema = void 0;
|
|
4
|
+
var config_validation_schema_1 = require("./config-validation-schema");
|
|
5
|
+
Object.defineProperty(exports, "configValidationSchema", { enumerable: true, get: function () { return config_validation_schema_1.configValidationSchema; } });
|
|
6
|
+
var config_loader_1 = require("./config-loader");
|
|
7
|
+
Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_loader_1.ConfigLoader; } });
|