ui5-test-runner 1.1.5 → 2.0.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/README.md +32 -188
- package/index.js +47 -16
- package/package.json +28 -10
- package/src/add-test-pages.js +35 -0
- package/src/add-test-pages.spec.js +95 -0
- package/src/browser.spec.js +724 -0
- package/src/browsers.js +220 -59
- package/src/capabilities/index.js +194 -0
- package/src/capabilities/tests/basic/iframe.html +8 -0
- package/src/capabilities/tests/basic/index.html +12 -0
- package/src/capabilities/tests/basic/index.js +20 -0
- package/src/capabilities/tests/basic/ui5.html +24 -0
- package/src/capabilities/tests/dynamic-include/index.js +21 -0
- package/src/capabilities/tests/dynamic-include/mix.html +11 -0
- package/src/capabilities/tests/dynamic-include/one.html +11 -0
- package/src/capabilities/tests/dynamic-include/post.js +3 -0
- package/src/capabilities/tests/dynamic-include/test.js +1 -0
- package/src/capabilities/tests/dynamic-include/two.html +11 -0
- package/src/capabilities/tests/index.js +16 -0
- package/src/capabilities/tests/local-storage/index.html +16 -0
- package/src/capabilities/tests/local-storage/index.js +21 -0
- package/src/capabilities/tests/screenshot/index.html +13 -0
- package/src/capabilities/tests/screenshot/index.js +18 -0
- package/src/capabilities/tests/scripts/index.js +50 -0
- package/src/capabilities/tests/scripts/qunit.html +22 -0
- package/src/capabilities/tests/scripts/testsuite.html +10 -0
- package/src/capabilities/tests/scripts/testsuite.js +8 -0
- package/src/capabilities/tests/timeout/index.html +21 -0
- package/src/capabilities/tests/timeout/index.js +19 -0
- package/src/capabilities/tests/traces/index.html +18 -0
- package/src/capabilities/tests/traces/index.js +81 -0
- package/src/cors.js +1 -1
- package/src/cors.spec.js +41 -0
- package/src/coverage.js +30 -18
- package/src/coverage.spec.js +79 -0
- package/src/csv-reader.js +36 -0
- package/src/csv-reader.spec.js +42 -0
- package/src/csv-writer.js +52 -0
- package/src/csv-writer.spec.js +77 -0
- package/src/defaults/browser.js +144 -0
- package/src/defaults/jsdom/compatibility.js +95 -0
- package/src/defaults/jsdom/debug.js +23 -0
- package/src/defaults/jsdom/resource-loader.js +43 -0
- package/src/defaults/jsdom/sap.ui.test.matchers.visible.js +39 -0
- package/src/defaults/jsdom.js +64 -0
- package/src/defaults/junit-xml-report.js +64 -0
- package/src/defaults/puppeteer.js +111 -0
- package/src/defaults/report/common.js +38 -0
- package/src/defaults/report/default.html +84 -0
- package/src/defaults/report/main.js +44 -0
- package/src/defaults/report/progress.js +49 -0
- package/src/defaults/report/styles.css +66 -0
- package/src/defaults/report.js +69 -0
- package/src/defaults/selenium-webdriver/chrome.js +38 -0
- package/src/defaults/selenium-webdriver/edge.js +25 -0
- package/src/defaults/selenium-webdriver/firefox.js +31 -0
- package/src/defaults/selenium-webdriver.js +138 -0
- package/src/endpoints.js +70 -124
- package/src/error.js +52 -0
- package/src/error.spec.js +17 -0
- package/src/get-job-progress.js +69 -0
- package/src/get-job-progress.spec.js +175 -0
- package/src/inject/post.js +96 -0
- package/src/inject/post.spec.js +147 -0
- package/src/inject/qunit-hooks.js +6 -21
- package/src/inject/qunit-intercept.js +30 -0
- package/src/inject/qunit-redirect.js +15 -7
- package/src/job-mode.js +45 -0
- package/src/job.js +254 -108
- package/src/job.spec.js +413 -0
- package/src/npm.js +73 -0
- package/src/npm.spec.js +98 -0
- package/src/options.js +73 -0
- package/src/options.spec.js +125 -0
- package/src/output.js +450 -131
- package/src/qunit-hooks.js +116 -0
- package/src/qunit-hooks.spec.js +687 -0
- package/src/report.js +47 -0
- package/src/reserve.js +3 -4
- package/src/simulate.spec.js +466 -0
- package/src/symbols.js +8 -0
- package/src/tests.js +127 -84
- package/src/timeout.spec.js +39 -0
- package/src/tools.js +111 -4
- package/src/tools.spec.js +90 -0
- package/src/ui5.js +3 -3
- package/src/unhandled.js +6 -6
- package/src/unhandled.spec.js +63 -0
- package/defaults/chromium.js +0 -62
- package/src/progress.html +0 -71
- package/src/proxies.js +0 -8
- package/src/report.html +0 -202
- /package/{defaults → src/defaults}/nyc.json +0 -0
package/README.md
CHANGED
|
@@ -4,210 +4,54 @@
|
|
|
4
4
|
[](https://packagequality.com/#?package=ui5-test-runner)
|
|
5
5
|
[](https://snyk.io/test/github/ArnaudBuchholz/ui5-test-runner?targetFile=package.json)
|
|
6
6
|
[](https://www.npmjs.org/package/ui5-test-runner)
|
|
7
|
+
[](https://packagephobia.com/result?p=ui5-test-runner)
|
|
7
8
|
[](https://opensource.org/licenses/MIT)
|
|
8
9
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2FArnaudBuchholz%2Fui5-test-runner?ref=badge_shield)
|
|
10
|
+
[](https://arnaudbuchholz.github.io/ui5-test-runner/)
|
|
9
11
|
|
|
10
12
|
A self-sufficient test runner for UI5 applications enabling parallel execution of tests.
|
|
11
13
|
|
|
12
|
-
> To put it in a nutshell, some applications have so many tests that when you run them in a browser, it ends up **crashing**. The main reason is **memory consumption** : the browser process goes up to 2 GB and it blows up. JavaScript is
|
|
14
|
+
> To put it in a nutshell, some UI5 applications have so many tests that when you run them in a browser, it ends up **crashing**. The main reason is **memory consumption** : the browser process goes up to 2 GB and it blows up. JavaScript is based on garbage collecting but it needs time to operate and the stress caused by executing the tests as well as the use of iframes do not let enough bandwidth for the browser to free up the memory.
|
|
13
15
|
|
|
14
16
|
> This tool is designed and built as a **substitute** of the [UI5 karma runner](https://github.com/SAP/karma-ui5). It executes all the tests in **parallel** thanks to several browser instances *(which also **reduces the total execution time**)*.
|
|
15
17
|
|
|
16
|
-
## Documentation
|
|
18
|
+
## 📚 [Documentation](https://arnaudbuchholz.github.io/ui5-test-runner/)
|
|
17
19
|
|
|
18
|
-
* Initial concept is detailed in the article [REserve - Testing UI5](https://arnaud-buchholz.medium.com/reserve-testing-ui5-85187d5eb7f1)
|
|
19
|
-
* Tool was presented during UI5Con'21 : [A different approach to UI5 tests execution](https://youtu.be/EBp0bdIqu4s)
|
|
20
20
|
|
|
21
|
-
## How to install
|
|
21
|
+
## 💿 How to install
|
|
22
22
|
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Works with [Node.js](https://nodejs.org/en/download/) >= 14
|
|
24
|
+
* Local installation
|
|
25
|
+
* `npm install --save-dev ui5-test-runner`
|
|
26
|
+
* Trigger either with `npx ui5-test-runner` or through an npm script invoking `ui5-test-runner`
|
|
27
|
+
* Global installation
|
|
28
|
+
* `npm install --global ui5-test-runner`
|
|
29
|
+
* Trigger with `ui5-test-runner`
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
**NOTE** : additional packages might be needed during the execution (`puppeteer`, `selenium-webdriver`, `nyc`...) . If they are found installed **locally** in the tested project, they are used. Otherwise, they are installed **globally**.
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
* Inside the project, use `npm run karma` to test with the karma runner
|
|
30
|
-
* Inside the project, use `ui5-test-runner -port:8080 -ui5:https://ui5.sap.com/1.87.0/ -cache:.ui5 -keepAlive`
|
|
31
|
-
* Follow the progress of the test executions using http://localhost:8080/_/progress.html
|
|
32
|
-
* When the tests are completed, inspect the results by opening :
|
|
33
|
-
- http://localhost:8080/_/report.html
|
|
34
|
-
- http://localhost:8080/_/coverage/lcov-report/index.html
|
|
35
|
-
|
|
36
|
-
## How to use
|
|
37
|
-
|
|
38
|
-
* Clone the project you want to test
|
|
39
|
-
* If the project owns library dependencies *(other than UI5)*, you must also clone them.<br/>
|
|
40
|
-
To check for project dependencies, you may look into :
|
|
41
|
-
- `POM.xml` *(for maven based builds)* :
|
|
42
|
-
```xml
|
|
43
|
-
<dependencies>
|
|
44
|
-
<dependency>
|
|
45
|
-
<groupId>com.sap.fiori</groupId>
|
|
46
|
-
<artifactId>my.namespace.feature.project.lib</artifactId>
|
|
47
|
-
<version>...</version>
|
|
48
|
-
</dependency>
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
- `manifest.json` file :
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"sap.ui5": {
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"libs": {
|
|
57
|
-
"my.namespace.feature.lib": {
|
|
58
|
-
"lazy": true
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
> The following assumes that the project and its dependencies are cloned in **the same** folder. You **must** handle the **differences** between the library **project name** / **structure** and the **namespace** it implements.
|
|
63
|
-
|
|
64
|
-
* In the project root folder, run the following command :
|
|
65
|
-
|
|
66
|
-
`ui5-test-runner -port:8080 -cache:.ui5 -libs:my/namespace/feature/lib/=../my.namespace.feature.project.lib/src/my/namespace/feature/lib/`
|
|
67
|
-
|
|
68
|
-
The list of options is detailed below but to explain the command :
|
|
69
|
-
* `-port:8080` : uses the fixed http port `8080`
|
|
70
|
-
|
|
71
|
-
* `-cache:.ui5` : caches UI5 resources to boost loading of pages. It stores resources in a project folder named `.ui5` *(you may use an absolute path if preferred)*.
|
|
72
|
-
|
|
73
|
-
* `-libs:my/namespace/feature/lib/=../my.namespace.feature.project.lib/src/my/namespace/feature/lib/` : maps the library path (access to URL `/resources/my/namespace/feature/lib/library.js` will be mapped to the file path `../my.namespace.feature.project.lib/src/my/namespace/feature/lib/library.js`)
|
|
74
|
-
|
|
75
|
-
You may also use :
|
|
76
|
-
* `-ui5:https://ui5.sap.com/1.92.1/` : uses a specific version of UI5
|
|
77
|
-
|
|
78
|
-
* `-coverage:false` : **ignores** code coverage measurement *(if you don’t need it, it speeds up a bit the startup)*
|
|
79
|
-
|
|
80
|
-
* `"-args:__URL__ __REPORT__ --visible"` : changes the browser spawning command line to make the browser windows **visible**
|
|
81
|
-
|
|
82
|
-
* `-parallel:3` : increases *(changes)* the number of parallel execution *(by default it uses 2)*. You may even use `0` to only serve the application *(the tests are not executed)*.
|
|
83
|
-
|
|
84
|
-
* `-keepAlive` : the server remains active after executing the tests
|
|
85
|
-
|
|
86
|
-
- It is a nice way to run the tests in your own browser.<br/>For instance, open http://localhost:8080/test/unit/unitTests.qunit.html
|
|
87
|
-
|
|
88
|
-
- It might be interesting to keep it running to access the detailed report *(see below)*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
**During** the test executions *(which can take some time)* you can monitor the progress by opening : http://localhost:8080/_/progress.html
|
|
92
|
-
|
|
93
|
-

|
|
94
|
-
|
|
95
|
-
**After** the tests are executed :
|
|
96
|
-
|
|
97
|
-
* The command line output will provide a summary of executed pages and the corresponding failures :
|
|
98
|
-
|
|
99
|
-

|
|
33
|
+
## 🖥️ How to demo
|
|
100
34
|
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
|
|
112
|
-
- `.nyc_output/` : contains coverage information
|
|
113
|
-
|
|
114
|
-
- `report/` : contains test report *(as well as screenshots and console log outputs)*
|
|
115
|
-
|
|
116
|
-
- `.ui5/` : contains cached UI5 resources
|
|
117
|
-
|
|
118
|
-
- These folder names can be changed through parameters *(see the list below)*
|
|
119
|
-
|
|
120
|
-
## Parameters
|
|
121
|
-
|
|
122
|
-
| name | default | description |
|
|
123
|
-
|---|---|---|
|
|
124
|
-
| cwd | `process.cwd()` | Current working directory |
|
|
125
|
-
| port | `0` | port to use (`0` to let REserve allocate one) |
|
|
126
|
-
| ui5 | `'https://ui5.sap.com'` | UI5 url |
|
|
127
|
-
| libs | | Folder(s) containing dependent libraries *(relative to `cwd`)*.<br/>Might be used multiple times, two syntaxes are supported :<ul><li>`-libs:path` adds `path` to the list of libraries, mapped directly under `/resources/`</li><li>`-libs:rel/=path` adds the `path` to the list of libraries, mapped under `/resources/rel/`</li></ul> |
|
|
128
|
-
| cache | `''` | Cache UI5 resources locally in the given folder *(empty to disable)* |
|
|
129
|
-
| webapp | `'webapp'` | base folder of the web application *(relative to `cwd`)* |
|
|
130
|
-
| testsuite | `'test/testsuite.qunit.html'` | path / URL to the testsuite file *(relative to `webapp`)* |
|
|
131
|
-
| pageFilter | `''` | [regexp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to select which pages to execute |
|
|
132
|
-
| pageParams | `''` | Parameters added to each page URL.<br/>For instance : `'sap-ui-theme=sap_belize&sap-ui-debug=true'` |
|
|
133
|
-
| pageTimeout | `0` | Limit the page execution time (ms), fails the page if it takes longer than the timeout (`0` to disable the timeout) |
|
|
134
|
-
| globalTimeout | `0` | Limit the pages execution time (ms), fails the execution if it takes longer than the timeout (`0` to disable the timeout) |
|
|
135
|
-
| failFast | `false` | Stops the execution after the first failing page |
|
|
136
|
-
| keepAlive | `false` | Keeps the server alive *(enables debugging)* |
|
|
137
|
-
| watch | `false` | Monitors the webapp folder and re-execute tests on change |
|
|
138
|
-
| logServer | `false` | Logs REserve traces |
|
|
139
|
-
| browser | *String, see description* | Browser instantiation command, it should point to a node.js script *(absolute or relative to `cwd`)*.<br/>By default, a script will instantiate chromium through puppetteer |
|
|
140
|
-
| browserRetry | `1` | Browser instantiation retries : if the command **fails** unexpectedly, it is re-executed *(`0` means no retry)*.<br/>The page **fails** if **all attempts** fail |
|
|
141
|
-
| args | `'__URL__ __REPORT__'` | Browser instantiation arguments :<ul><li>`'__URL__'` is replaced with the URL to open</li><li>`'__REPORT__'` is replaced with a folder path that is associated with the current URL *(can be used to store additional traces such as console logs or screenshots)*</li><li>`'__RETRY__'` is replaced with the retry count *(0 for the first execution, can be used to put additional traces or change strategy)*</i>*</li></ul> |
|
|
142
|
-
| noScreenshot | `false` | No screenshot is taken during the tests execution (faster if the browser command supports screenshot) |
|
|
143
|
-
| -- | | Parameters given right after `--` are directly added to the browser instantiation arguments *(see below)* |
|
|
144
|
-
| parallel | `2` | Number of parallel tests executions (`0` to ignore tests and keep alive) |
|
|
145
|
-
| tstReportDir | `'report'` | Directory to output test reports *(relative to `cwd`)* |
|
|
146
|
-
| coverage | `true` | Enables code coverage |
|
|
147
|
-
| covSettings | *String, see description* | Path to a custom `nyc.json` file providing settings for instrumentation *(relative to `cwd`)* |
|
|
148
|
-
| covTempDir | `'.nyc_output'` | Directory to output raw coverage information to *(relative to `cwd`)* |
|
|
149
|
-
| covReportDir | `'coverage'` | Where to put the coverage report files *(relative to `cwd`)* |
|
|
150
|
-
| covReporters | `'lcov,cobertura'` | Comma separated list of reporters to use |
|
|
151
|
-
|
|
152
|
-
These two commands are equivalent :
|
|
153
|
-
|
|
154
|
-
```text
|
|
155
|
-
ui5-test-runner "-args:__URL__ __REPORT__ --visible"
|
|
156
|
-
ui5-test-runner -- --visible
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Configuration file
|
|
160
|
-
|
|
161
|
-
It is also possible to set these parameters by creating a JSON file named `ui5-test-runner.json` where the **runner is executed** *(i.e. `process.cwd()`)*.
|
|
162
|
-
|
|
163
|
-
The file is applied **before** parsing the command line parameters, hence some parameters might be **overridden**.
|
|
164
|
-
|
|
165
|
-
If you want the parameters to be **forced** *(and not be overridden by the command line)*, prefix the parameter name with `!`.
|
|
166
|
-
|
|
167
|
-
For example :
|
|
168
|
-
```json
|
|
169
|
-
{
|
|
170
|
-
"!pageTimeout": 900000,
|
|
171
|
-
"globalTimeout": 3600000,
|
|
172
|
-
"failFast": true
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
> The `pageTimeout` setting cannot be overridden by the command line parameters
|
|
177
|
-
|
|
178
|
-
**NOTE** : the `libs` parameters must be converted to an array of pairs associating `relative` URL and `source` path.
|
|
179
|
-
|
|
180
|
-
For instance :
|
|
181
|
-
|
|
182
|
-
```json
|
|
183
|
-
{
|
|
184
|
-
"libs": [{
|
|
185
|
-
"relative": "my/namespace/feature/lib/",
|
|
186
|
-
"source": "../my.namespace.feature.project.lib/src/my/namespace/feature/lib/"
|
|
187
|
-
}]
|
|
188
|
-
}
|
|
189
|
-
```
|
|
35
|
+
* Clone the project [training-ui5con18-opa](https://github.com/ArnaudBuchholz/training-ui5con18-opa) and run `npm install`
|
|
36
|
+
* Use `npm run karma` to test with the karma runner
|
|
37
|
+
* *Serving the application (a.k.a. legacy mode)*
|
|
38
|
+
* `npx ui5-test-runner --port 8081 --ui5 https://ui5.sap.com/1.109.0/ --cache .ui5 --keep-alive`
|
|
39
|
+
* Follow the progress of the test executions using http://localhost:8081/_/progress.html
|
|
40
|
+
* When the tests are completed, check the code coverage with http://localhost:8081/_/coverage/lcov-report/index.html
|
|
41
|
+
* *Serving the application with `@ui5/cli`*
|
|
42
|
+
* Use `npm start` to serve the application with `@ui5/cli`
|
|
43
|
+
* `npx ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html --keep-alive`
|
|
44
|
+
* Follow the progress of the test executions using http://localhost:8081/_/progress.html
|
|
190
45
|
|
|
191
|
-
> Structure of the `libs` parameter
|
|
192
46
|
|
|
193
|
-
##
|
|
47
|
+
## ⚖️ License
|
|
48
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2FArnaudBuchholz%2Fui5-test-runner?ref=badge_large)
|
|
194
49
|
|
|
195
|
-
|
|
196
|
-
* To benefit from **parallelization**, split the OPA test pages per journey.<br> An example pattern :
|
|
197
|
-
- **Declare** the list of journeys in a json file : [`AllJourneys.json`](https://github.com/ArnaudBuchholz/training-ui5con18-opa/blob/master/webapp/test/integration/AllJourneys.json)
|
|
198
|
-
- **Enumerate** `AllJourneys.json` in [`testsuite.qunit.html`](https://github.com/ArnaudBuchholz/training-ui5con18-opa/blob/master/webapp/test/testsuite.qunit.html#L17) to declare as many pages as journeys
|
|
199
|
-
- **Modify** [`AllJourneys.js`](https://github.com/ArnaudBuchholz/training-ui5con18-opa/blob/master/webapp/test/integration/AllJourneys.js#L26) to support a `journey=` parameter and list all declared journeys
|
|
50
|
+
## ⚠️ Breaking change
|
|
200
51
|
|
|
201
|
-
|
|
52
|
+
### v2
|
|
202
53
|
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
- `message.command === 'capabilities'` : a message must be sent back to indicate if the following features are supported *(boolean)*
|
|
208
|
-
- `screenshot` : the browser can take screenshots (in the `__REPORT__` folder, name is provided when needed)
|
|
209
|
-
- `consoleLog` : the browser serializes the console traces (in the `__REPORT__` folder with the name `console.txt`)
|
|
210
|
-
- `message.command === 'screenshot'` : should generate a screenshot (the message contains a `filename` member). To indicate that the screenshot is done, the command line must send back the same message (`process.send(message)`).
|
|
211
|
-
|
|
212
|
-
## License
|
|
213
|
-
[](https://app.fossa.com/projects/git%2Bgithub.com%2FArnaudBuchholz%2Fui5-test-runner?ref=badge_large)
|
|
54
|
+
* Command line **parameters** as well as configuration file **syntax** have changed
|
|
55
|
+
* Dependencies are installed **on demand**
|
|
56
|
+
* Browser instantiation command evolved in an **incompatible way** (see [documentation](https://arnaudbuchholz.github.io/ui5-test-runner/browser.html)).
|
|
57
|
+
* Output is different (report, traces)
|
package/index.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
const
|
|
5
|
+
const { serve } = require('reserve')
|
|
6
|
+
const { fromCmdLine } = require('./src/job')
|
|
7
|
+
const { getOutput } = require('./src/output')
|
|
8
8
|
const reserveConfigurationFactory = require('./src/reserve')
|
|
9
|
-
const
|
|
9
|
+
const { execute } = require('./src/tests')
|
|
10
|
+
const { capabilities } = require('./src/capabilities')
|
|
10
11
|
const { watch } = require('fs')
|
|
12
|
+
const { recreateDir } = require('./src/tools')
|
|
11
13
|
|
|
12
14
|
function send (message) {
|
|
13
15
|
if (process.send) {
|
|
@@ -18,32 +20,48 @@ function send (message) {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
async function notifyAndExecuteTests (job) {
|
|
23
|
+
async function notifyAndExecuteTests (job, output) {
|
|
22
24
|
send({ msg: 'begin' })
|
|
23
25
|
try {
|
|
24
|
-
await
|
|
25
|
-
|
|
26
|
+
await execute(job)
|
|
27
|
+
let status
|
|
28
|
+
if (job.failed) {
|
|
29
|
+
status = -1
|
|
30
|
+
} else {
|
|
31
|
+
status = 0
|
|
32
|
+
}
|
|
33
|
+
send({ msg: 'end', status })
|
|
26
34
|
} catch (error) {
|
|
27
|
-
|
|
35
|
+
getOutput(job).genericError(error)
|
|
28
36
|
send({ msg: 'error', error })
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
|
|
40
|
+
let job
|
|
41
|
+
let output
|
|
42
|
+
|
|
32
43
|
async function main () {
|
|
33
|
-
|
|
44
|
+
job = fromCmdLine(process.cwd(), process.argv.slice(2))
|
|
45
|
+
output = getOutput(job)
|
|
46
|
+
await recreateDir(job.reportDir)
|
|
47
|
+
if (job.mode === 'capabilities') {
|
|
48
|
+
output.version()
|
|
49
|
+
return capabilities(job)
|
|
50
|
+
}
|
|
34
51
|
const configuration = await reserveConfigurationFactory(job)
|
|
35
52
|
const server = serve(configuration)
|
|
36
53
|
if (job.logServer) {
|
|
37
|
-
|
|
54
|
+
server.on('redirected', output.redirected)
|
|
38
55
|
}
|
|
39
56
|
server
|
|
40
57
|
.on('ready', async ({ url, port }) => {
|
|
41
58
|
job.port = port
|
|
42
59
|
send({ msg: 'ready', port: job.port })
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
output.serving(url)
|
|
61
|
+
if (job.serveOnly) {
|
|
62
|
+
return
|
|
45
63
|
}
|
|
46
|
-
output.
|
|
64
|
+
output.reportOnJobProgress()
|
|
47
65
|
await notifyAndExecuteTests(job)
|
|
48
66
|
if (job.watch) {
|
|
49
67
|
delete job.start
|
|
@@ -59,14 +77,27 @@ async function main () {
|
|
|
59
77
|
}
|
|
60
78
|
} else if (job.keepAlive) {
|
|
61
79
|
job.status = 'Serving'
|
|
80
|
+
} else if (job.failed) {
|
|
81
|
+
output.stop()
|
|
82
|
+
process.exit(-1)
|
|
62
83
|
} else {
|
|
63
|
-
|
|
84
|
+
output.stop()
|
|
85
|
+
process.exit(0)
|
|
64
86
|
}
|
|
65
87
|
})
|
|
66
88
|
.on('error', error => {
|
|
67
|
-
output.
|
|
89
|
+
output.serverError(error)
|
|
68
90
|
send({ msg: 'error', error })
|
|
69
91
|
})
|
|
70
92
|
}
|
|
71
93
|
|
|
72
|
-
main()
|
|
94
|
+
main()
|
|
95
|
+
.catch(reason => {
|
|
96
|
+
if (output) {
|
|
97
|
+
output.genericError(reason)
|
|
98
|
+
output.stop()
|
|
99
|
+
} else if (reason.name !== 'CommanderError') {
|
|
100
|
+
console.error(reason)
|
|
101
|
+
}
|
|
102
|
+
process.exit(-1)
|
|
103
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui5-test-runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Standalone test runner for UI5",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"lint": "standard --fix",
|
|
19
|
-
"test": "
|
|
20
|
-
"test:
|
|
19
|
+
"test": "npm run test:unit && npm run test:integration:jsdom && npm run test:integration:puppeteer && npm run test:integration:selenium-webdriver-chrome",
|
|
20
|
+
"test:unit": "jest",
|
|
21
|
+
"test:unit:debug": "jest --runInBand",
|
|
22
|
+
"test:integration:puppeteer": "node . --capabilities --browser $/puppeteer.js",
|
|
23
|
+
"test:integration:selenium-webdriver-chrome": "node . --capabilities --browser $/selenium-webdriver.js -- --browser chrome",
|
|
24
|
+
"test:integration:jsdom": "node . --capabilities --browser $/jsdom.js",
|
|
25
|
+
"test:report": "reserve --config ./test/report/reserve.json",
|
|
26
|
+
"build:doc": "node build/doc"
|
|
21
27
|
},
|
|
22
28
|
"repository": {
|
|
23
29
|
"type": "git",
|
|
@@ -39,16 +45,21 @@
|
|
|
39
45
|
},
|
|
40
46
|
"homepage": "https://github.com/ArnaudBuchholz/ui5-test-runner#readme",
|
|
41
47
|
"dependencies": {
|
|
48
|
+
"commander": "^10.0.0",
|
|
42
49
|
"mime": "^3.0.0",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
50
|
+
"punybind": "^1.2.1",
|
|
51
|
+
"punyexpr": "^1.0.4",
|
|
45
52
|
"reserve": "^1.15.2"
|
|
46
53
|
},
|
|
47
54
|
"devDependencies": {
|
|
48
|
-
"jest": "^29.
|
|
49
|
-
"nock": "^13.
|
|
55
|
+
"jest": "^29.5.0",
|
|
56
|
+
"nock": "^13.3.0",
|
|
57
|
+
"nyc": "^15.1.0",
|
|
50
58
|
"standard": "^17.0.0"
|
|
51
59
|
},
|
|
60
|
+
"optionalDependencies": {
|
|
61
|
+
"fsevents": "^2.3.2"
|
|
62
|
+
},
|
|
52
63
|
"standard": {
|
|
53
64
|
"env": [
|
|
54
65
|
"browser",
|
|
@@ -58,15 +69,22 @@
|
|
|
58
69
|
]
|
|
59
70
|
},
|
|
60
71
|
"jest": {
|
|
72
|
+
"testTimeout": 15000,
|
|
61
73
|
"setupFilesAfterEnv": [
|
|
62
|
-
"./
|
|
74
|
+
"./test/setup.js"
|
|
75
|
+
],
|
|
76
|
+
"testPathIgnorePatterns": [
|
|
77
|
+
"/node_modules/",
|
|
78
|
+
"/capabilities/"
|
|
63
79
|
],
|
|
64
80
|
"collectCoverage": true,
|
|
65
81
|
"collectCoverageFrom": [
|
|
66
82
|
"src/*.js"
|
|
67
83
|
],
|
|
68
84
|
"coveragePathIgnorePatterns": [
|
|
69
|
-
"
|
|
85
|
+
"\\.spec\\.js",
|
|
86
|
+
"output\\.js",
|
|
87
|
+
"b\\capabilities\\b"
|
|
70
88
|
],
|
|
71
89
|
"coverageThreshold": {
|
|
72
90
|
"global": {
|
|
@@ -77,4 +95,4 @@
|
|
|
77
95
|
}
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
|
-
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { stop } = require('./browsers')
|
|
4
|
+
const { URL } = require('url')
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
async addTestPages (job, url, pages) {
|
|
8
|
+
let testPageUrls
|
|
9
|
+
pages = pages.map(relativeUrl => {
|
|
10
|
+
const absoluteUrl = new URL(relativeUrl, url)
|
|
11
|
+
return absoluteUrl.toString()
|
|
12
|
+
})
|
|
13
|
+
if (job.pageFilter) {
|
|
14
|
+
const filter = new RegExp(job.pageFilter)
|
|
15
|
+
testPageUrls = pages.filter(name => name.match(filter))
|
|
16
|
+
} else {
|
|
17
|
+
testPageUrls = pages
|
|
18
|
+
}
|
|
19
|
+
if (job.pageParams) {
|
|
20
|
+
testPageUrls = testPageUrls.map(url => {
|
|
21
|
+
if (url.includes('?')) {
|
|
22
|
+
return url + '&' + job.pageParams
|
|
23
|
+
}
|
|
24
|
+
return url + '?' + job.pageParams
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
job.testPageUrls = testPageUrls.reduce((uniques, url) => {
|
|
28
|
+
if (!uniques.includes(url)) {
|
|
29
|
+
uniques.push(url)
|
|
30
|
+
}
|
|
31
|
+
return uniques
|
|
32
|
+
}, job.testPageUrls || [])
|
|
33
|
+
stop(job, url)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
jest.mock('./browsers.js', () => ({
|
|
2
|
+
stop: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
const { stop } = require('./browsers')
|
|
5
|
+
const { join } = require('path')
|
|
6
|
+
const { createDir } = require('./tools')
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
addTestPages
|
|
10
|
+
} = require('./add-test-pages')
|
|
11
|
+
|
|
12
|
+
describe('src/add-test-pages', () => {
|
|
13
|
+
const url = 'http://localhost:8045/index.html'
|
|
14
|
+
const reportDir = join(__dirname, '../tmp/add-test-pages')
|
|
15
|
+
let job
|
|
16
|
+
|
|
17
|
+
beforeAll(() => createDir(reportDir))
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
stop.mockClear()
|
|
21
|
+
job = {
|
|
22
|
+
reportDir
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('addTestPages', () => {
|
|
27
|
+
it('keeps track of added test pages and stops browser', async () => {
|
|
28
|
+
await addTestPages(job, url, [
|
|
29
|
+
'/page1.html',
|
|
30
|
+
'page2.html'
|
|
31
|
+
])
|
|
32
|
+
expect(job.testPageUrls).toEqual([
|
|
33
|
+
'http://localhost:8045/page1.html',
|
|
34
|
+
'http://localhost:8045/page2.html'
|
|
35
|
+
])
|
|
36
|
+
expect(stop).toHaveBeenCalledWith(job, url)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('supports regexp filtering', async () => {
|
|
40
|
+
job.pageFilter = 'page(1|3)'
|
|
41
|
+
await addTestPages(job, url, [
|
|
42
|
+
'/page1.html',
|
|
43
|
+
'page2.html',
|
|
44
|
+
'page3.html'
|
|
45
|
+
])
|
|
46
|
+
expect(job.testPageUrls).toEqual([
|
|
47
|
+
'http://localhost:8045/page1.html',
|
|
48
|
+
'http://localhost:8045/page3.html'
|
|
49
|
+
])
|
|
50
|
+
expect(stop).toHaveBeenCalledWith(job, url)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('supports parameters injection', async () => {
|
|
54
|
+
job.pageParams = 'a&b'
|
|
55
|
+
await addTestPages(job, url, [
|
|
56
|
+
'/page1.html',
|
|
57
|
+
'page2.html?test'
|
|
58
|
+
])
|
|
59
|
+
expect(job.testPageUrls).toEqual([
|
|
60
|
+
'http://localhost:8045/page1.html?a&b',
|
|
61
|
+
'http://localhost:8045/page2.html?test&a&b'
|
|
62
|
+
])
|
|
63
|
+
expect(stop).toHaveBeenCalledWith(job, url)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('filters out duplicates', async () => {
|
|
67
|
+
await addTestPages(job, url, [
|
|
68
|
+
'/page1.html',
|
|
69
|
+
'page1.html'
|
|
70
|
+
])
|
|
71
|
+
expect(job.testPageUrls).toEqual([
|
|
72
|
+
'http://localhost:8045/page1.html'
|
|
73
|
+
])
|
|
74
|
+
expect(stop).toHaveBeenCalledWith(job, url)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('supports multiple calls', async () => {
|
|
78
|
+
await addTestPages(job, url, ['/page1.html'])
|
|
79
|
+
await addTestPages(job, url, ['page1.html', '/page2.html'])
|
|
80
|
+
expect(job.testPageUrls).toEqual([
|
|
81
|
+
'http://localhost:8045/page1.html',
|
|
82
|
+
'http://localhost:8045/page2.html'
|
|
83
|
+
])
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('supports absolute urls', async () => {
|
|
87
|
+
await addTestPages(job, url, ['/page1.html'])
|
|
88
|
+
await addTestPages(job, url, ['http://localhost:8045/page2.html'])
|
|
89
|
+
expect(job.testPageUrls).toEqual([
|
|
90
|
+
'http://localhost:8045/page1.html',
|
|
91
|
+
'http://localhost:8045/page2.html'
|
|
92
|
+
])
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
})
|