ui5-test-runner 1.1.1 → 1.1.4
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 +1 -2
- package/index.js +1 -1
- package/package.json +9 -6
- package/src/coverage.js +9 -0
- package/src/endpoints.js +21 -17
- package/src/job.js +16 -0
- package/src/output.js +1 -1
- package/src/tests.js +1 -1
package/README.md
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
[](https://github.com/ArnaudBuchholz/ui5-test-runner/actions/workflows/node.js.yml)
|
|
4
4
|
[](https://packagequality.com/#?package=ui5-test-runner)
|
|
5
5
|
[](https://snyk.io/test/github/ArnaudBuchholz/ui5-test-runner?targetFile=package.json)
|
|
6
|
-
[](https://david-dm.org/ArnaudBuchholz/ui5-test-runner)
|
|
7
|
-
[](https://david-dm.org/ArnaudBuchholz/ui5-test-runner?type=dev)
|
|
8
6
|
[](https://www.npmjs.org/package/ui5-test-runner)
|
|
9
7
|
[](https://opensource.org/licenses/MIT)
|
|
10
8
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2FArnaudBuchholz%2Fui5-test-runner?ref=badge_shield)
|
|
@@ -129,6 +127,7 @@ You may also use :
|
|
|
129
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> |
|
|
130
128
|
| cache | `''` | Cache UI5 resources locally in the given folder *(empty to disable)* |
|
|
131
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`)* |
|
|
132
131
|
| pageFilter | `''` | [regexp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to select which pages to execute |
|
|
133
132
|
| pageParams | `''` | Parameters added to each page URL.<br/>For instance : `'sap-ui-theme=sap_belize&sap-ui-debug=true'` |
|
|
134
133
|
| pageTimeout | `0` | Limit the page execution time (ms), fails the page if it takes longer than the timeout (`0` to disable the timeout) |
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui5-test-runner",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Standalone test runner for UI5",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/ArnaudBuchholz/ui5-test-runner#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"mime": "^
|
|
42
|
+
"mime": "^3.0.0",
|
|
43
43
|
"nyc": "^15.1.0",
|
|
44
|
-
"puppeteer": "^
|
|
45
|
-
"reserve": "^1.
|
|
44
|
+
"puppeteer": "^13.5.2",
|
|
45
|
+
"reserve": "^1.14.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"jest": "^27.
|
|
49
|
-
"nock": "^13.
|
|
48
|
+
"jest": "^27.5.1",
|
|
49
|
+
"nock": "^13.2.4",
|
|
50
50
|
"standard": "^16.0.4"
|
|
51
51
|
},
|
|
52
52
|
"standard": {
|
|
@@ -58,6 +58,9 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"jest": {
|
|
61
|
+
"setupFilesAfterEnv": [
|
|
62
|
+
"./__mocks__/setup.js"
|
|
63
|
+
],
|
|
61
64
|
"collectCoverage": true,
|
|
62
65
|
"collectCoverageFrom": [
|
|
63
66
|
"src/*.js"
|
package/src/coverage.js
CHANGED
|
@@ -44,6 +44,15 @@ async function instrument (job) {
|
|
|
44
44
|
await createDir(join(job.covTempDir, 'settings'))
|
|
45
45
|
const settings = JSON.parse((await readFile(job.covSettings)).toString())
|
|
46
46
|
settings.cwd = job.cwd
|
|
47
|
+
if (!settings.exclude) {
|
|
48
|
+
settings.exclude = []
|
|
49
|
+
}
|
|
50
|
+
settings.exclude.push(join(job.covTempDir, '**'))
|
|
51
|
+
if (job.cache) {
|
|
52
|
+
settings.exclude.push(join(job.cache, '**'))
|
|
53
|
+
}
|
|
54
|
+
settings.exclude.push(join(job.tstReportDir, '**'))
|
|
55
|
+
settings.exclude.push(join(job.covReportDir, '**'))
|
|
47
56
|
await writeFile(job.nycSettingsPath, JSON.stringify(settings))
|
|
48
57
|
await nyc('instrument', job.webapp, join(job.covTempDir, 'instrumented'), '--nycrc-path', job.nycSettingsPath)
|
|
49
58
|
}
|
package/src/endpoints.js
CHANGED
|
@@ -38,6 +38,17 @@ module.exports = job => {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
function getPageTest (page, testId) {
|
|
42
|
+
const { tests, order } = page
|
|
43
|
+
if (!tests[testId]) {
|
|
44
|
+
tests[testId] = {
|
|
45
|
+
timestamps: []
|
|
46
|
+
}
|
|
47
|
+
order.push(testId)
|
|
48
|
+
}
|
|
49
|
+
return tests[testId]
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
return job.parallel
|
|
42
53
|
? [{
|
|
43
54
|
// Substitute qunit-redirect to extract test pages
|
|
@@ -105,34 +116,27 @@ module.exports = job => {
|
|
|
105
116
|
// Endpoint to receive QUnit.begin
|
|
106
117
|
match: '^/_/QUnit/begin',
|
|
107
118
|
custom: endpoint((url, details) => {
|
|
108
|
-
const
|
|
109
|
-
const order = []
|
|
110
|
-
details.modules.forEach(module => {
|
|
111
|
-
module.tests.forEach(test => {
|
|
112
|
-
tests[test.testId] = {
|
|
113
|
-
...test,
|
|
114
|
-
timestamps: []
|
|
115
|
-
}
|
|
116
|
-
order.push(test.testId)
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
job.testPages[url] = {
|
|
119
|
+
const page = {
|
|
120
120
|
isOpa: details.isOpa,
|
|
121
121
|
total: details.totalTests,
|
|
122
122
|
failed: 0,
|
|
123
123
|
passed: 0,
|
|
124
|
-
tests,
|
|
125
|
-
order
|
|
124
|
+
tests: {},
|
|
125
|
+
order: []
|
|
126
126
|
}
|
|
127
|
+
details.modules.forEach(module => {
|
|
128
|
+
module.tests.forEach(test => getPageTest(page, test.testId))
|
|
129
|
+
})
|
|
130
|
+
job.testPages[url] = page
|
|
127
131
|
})
|
|
128
132
|
}, {
|
|
129
|
-
// Endpoint to receive QUnit.
|
|
133
|
+
// Endpoint to receive QUnit.log
|
|
130
134
|
match: '^/_/QUnit/log',
|
|
131
135
|
custom: synchronousEndpoint(async (url, report) => {
|
|
132
136
|
const page = job.testPages[url]
|
|
133
137
|
if (page.isOpa) {
|
|
134
138
|
const { testId, runtime } = report
|
|
135
|
-
page
|
|
139
|
+
getPageTest(page, testId).timestamps.push(runtime)
|
|
136
140
|
await screenshot(job, url, `${testId}-${runtime}.png`)
|
|
137
141
|
}
|
|
138
142
|
})
|
|
@@ -149,7 +153,7 @@ module.exports = job => {
|
|
|
149
153
|
} else {
|
|
150
154
|
++page.passed
|
|
151
155
|
}
|
|
152
|
-
page
|
|
156
|
+
getPageTest(page, testId).report = report
|
|
153
157
|
})
|
|
154
158
|
}, {
|
|
155
159
|
// Endpoint to receive QUnit.done
|
package/src/job.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { accessSync } = require('fs')
|
|
3
4
|
const { join, isAbsolute } = require('path')
|
|
4
5
|
const output = require('./output')
|
|
5
6
|
|
|
@@ -12,6 +13,7 @@ function allocate (cwd) {
|
|
|
12
13
|
libs: [],
|
|
13
14
|
cache: '',
|
|
14
15
|
webapp: 'webapp',
|
|
16
|
+
testsuite: 'test/testsuite.qunit.html',
|
|
15
17
|
pageFilter: '',
|
|
16
18
|
pageParams: '',
|
|
17
19
|
pageTimeout: 0,
|
|
@@ -37,6 +39,14 @@ function allocate (cwd) {
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
function checkAccess (path, label) {
|
|
43
|
+
try {
|
|
44
|
+
accessSync(path)
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error(`Unable to access ${label}, check your settings`)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
function finalize (job) {
|
|
41
51
|
Object.keys(job)
|
|
42
52
|
.filter(name => name.startsWith('!'))
|
|
@@ -57,9 +67,15 @@ function finalize (job) {
|
|
|
57
67
|
'webapp,browser,tstReportDir,covSettings,covTempDir,covReportDir'
|
|
58
68
|
.split(',')
|
|
59
69
|
.forEach(setting => updateToAbsolute(setting))
|
|
70
|
+
checkAccess(job.webapp, 'webapp folder')
|
|
71
|
+
checkAccess(job.browser, 'browser command')
|
|
72
|
+
|
|
73
|
+
const testsuitePath = toAbsolute(job.testsuite, job.webapp)
|
|
74
|
+
checkAccess(testsuitePath, 'testsuite')
|
|
60
75
|
|
|
61
76
|
job.libs.forEach(libMapping => {
|
|
62
77
|
libMapping.source = toAbsolute(libMapping.source)
|
|
78
|
+
checkAccess(libMapping.source, `lib mapping of ${libMapping.relative}`)
|
|
63
79
|
})
|
|
64
80
|
|
|
65
81
|
if (job.parallel <= 0) {
|
package/src/output.js
CHANGED
|
@@ -188,7 +188,7 @@ module.exports = {
|
|
|
188
188
|
console.error(`Unable to cache '${path}' (status ${statusCode})`)
|
|
189
189
|
},
|
|
190
190
|
genericError (error) {
|
|
191
|
-
console.error('An unexpected error occurred', error)
|
|
191
|
+
console.error('An unexpected error occurred :', error.message || error)
|
|
192
192
|
},
|
|
193
193
|
unhandled () {
|
|
194
194
|
console.warn('Some requests are not handled properly, check the unhandled.txt report for more info')
|
package/src/tests.js
CHANGED
|
@@ -26,7 +26,7 @@ async function extractTestPages (job) {
|
|
|
26
26
|
await saveJob(job)
|
|
27
27
|
job.status = 'Extracting test pages'
|
|
28
28
|
job.testPageUrls = []
|
|
29
|
-
await start(job, '/
|
|
29
|
+
await start(job, '/' + job.testsuite)
|
|
30
30
|
if (job.testPageUrls.length === 0) {
|
|
31
31
|
output.noTestPageFound()
|
|
32
32
|
job.failed = true
|