ui5-test-runner 3.3.0 โ 3.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/package.json +1 -1
- package/src/coverage.js +10 -2
- package/src/defaults/junit-xml-report.js +2 -0
- package/src/defaults/puppeteer.js +19 -3
- package/src/job.js +5 -4
- package/src/tools.js +8 -1
- package/src/ui5.js +1 -1
- package/src/unhandled.js +1 -1
package/package.json
CHANGED
package/src/coverage.js
CHANGED
|
@@ -151,6 +151,7 @@ module.exports = {
|
|
|
151
151
|
coverageGlobalScopeFunc: false
|
|
152
152
|
})
|
|
153
153
|
const instrument = promisify(instrumenter.instrument.bind(instrumenter))
|
|
154
|
+
const sources = {}
|
|
154
155
|
return [{
|
|
155
156
|
match: /(.*\.js)(\?.*)?$/,
|
|
156
157
|
custom: async (request, response, url) => {
|
|
@@ -161,8 +162,15 @@ module.exports = {
|
|
|
161
162
|
try {
|
|
162
163
|
await access(sourcePath, constants.R_OK)
|
|
163
164
|
} catch (e) {
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
try {
|
|
166
|
+
if (sources[url]) {
|
|
167
|
+
await sources[url]
|
|
168
|
+
} else {
|
|
169
|
+
sources[url] = await download(origin + url, sourcePath)
|
|
170
|
+
}
|
|
171
|
+
} catch (statusCode) {
|
|
172
|
+
return statusCode
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
175
|
const source = (await readFile(sourcePath)).toString()
|
|
168
176
|
const instrumentedSource = await instrument(source, sourcePath)
|
|
@@ -12,10 +12,26 @@ require('./browser')({
|
|
|
12
12
|
['-h, --viewport-height <height>', 'Viewport height', 1080],
|
|
13
13
|
['-l, --language <lang...>', 'Language(s)', ['en-US']],
|
|
14
14
|
['-u, --unsecure', 'Disable security features', false]
|
|
15
|
-
],
|
|
16
|
-
|
|
15
|
+
] // ,
|
|
16
|
+
// TODO restore when Node16 is no more supported
|
|
17
|
+
// capabilities: {
|
|
18
|
+
// modules: ['puppeteer'],
|
|
19
|
+
// screenshot: '.png',
|
|
20
|
+
// scripts: true,
|
|
21
|
+
// traces: ['console', 'network']
|
|
22
|
+
// }
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// TODO remove when Node16 is no more supported
|
|
26
|
+
async capabilities () {
|
|
27
|
+
const version = process.version.match(/^v(\d+\.\d+)/)[1]
|
|
28
|
+
let screenshot
|
|
29
|
+
if (!version.startsWith('16')) {
|
|
30
|
+
screenshot = '.png'
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
17
33
|
modules: ['puppeteer'],
|
|
18
|
-
screenshot
|
|
34
|
+
screenshot,
|
|
19
35
|
scripts: true,
|
|
20
36
|
traces: ['console', 'network']
|
|
21
37
|
}
|
package/src/job.js
CHANGED
|
@@ -106,7 +106,7 @@ function getCommand (cwd) {
|
|
|
106
106
|
.option('-bt, --browser-close-timeout <timeout>', '[๐ป๐๐งช] Maximum waiting time for browser close', timeout, 2000)
|
|
107
107
|
.option('-br, --browser-retry <count>', '[๐ป๐๐งช] Browser instantiation retries : if the command fails unexpectedly, it is re-executed (0 means no retry)', 1)
|
|
108
108
|
|
|
109
|
-
// Common to legacy and
|
|
109
|
+
// Common to legacy and url
|
|
110
110
|
.option('-pf, --page-filter <regexp>', '[๐ป๐] Filter out pages not matching the regexp')
|
|
111
111
|
.option('-pp, --page-params <params>', '[๐ป๐] Add parameters to page URL')
|
|
112
112
|
.option('-t, --global-timeout <timeout>', '[๐ป๐] Limit the pages execution time, fail the page if it takes longer than the timeout (0 means no timeout)', timeout, 0)
|
|
@@ -124,8 +124,9 @@ function getCommand (cwd) {
|
|
|
124
124
|
.option('-cr, --coverage-reporters <reporter...>', '[๐ป๐] List of nyc reporters to use', ['lcov', 'cobertura'])
|
|
125
125
|
.option('-s, --serve-only [flag]', '[๐ป๐] Serve only', boolean, false)
|
|
126
126
|
|
|
127
|
-
// Specific to legacy
|
|
127
|
+
// Specific to legacy (and might be used with url if pointing to local project)
|
|
128
128
|
.option('--ui5 <url>', '[๐ป] UI5 url', url, 'https://ui5.sap.com')
|
|
129
|
+
.option('--no-ui5', '[๐ป] Disable UI5 mapping (also disable libs)')
|
|
129
130
|
.option('--libs <lib...>', '[๐ป] Library mapping (<relative>=<path> or <path>)', arrayOf(lib))
|
|
130
131
|
.option('--mappings <mapping...>', '[๐ป] Custom mapping (<match>=<file|url>(<config>))', arrayOf(mapping))
|
|
131
132
|
.option('--cache <path>', '[๐ป] Cache UI5 resources locally in the given folder (empty to disable)')
|
|
@@ -135,8 +136,8 @@ function getCommand (cwd) {
|
|
|
135
136
|
|
|
136
137
|
// Specific to coverage in url mode (experimental)
|
|
137
138
|
.option('-cp, --coverage-proxy [flag]', `[๐] ${EXPERIMENTAL_OPTION} use internal proxy to instrument remote files`, boolean, false)
|
|
138
|
-
.option('-cpi, --coverage-proxy-include <regexp>', `[๐] ${EXPERIMENTAL_OPTION} urls to instrument for coverage`, regex, regex('
|
|
139
|
-
.option('-cpe, --coverage-proxy-exclude <regexp>', `[๐] ${EXPERIMENTAL_OPTION} urls to ignore for coverage`, regex, regex('(test-)?resources/.*'))
|
|
139
|
+
.option('-cpi, --coverage-proxy-include <regexp>', `[๐] ${EXPERIMENTAL_OPTION} urls to instrument for coverage`, regex, regex('.*'))
|
|
140
|
+
.option('-cpe, --coverage-proxy-exclude <regexp>', `[๐] ${EXPERIMENTAL_OPTION} urls to ignore for coverage`, regex, regex('/((test-)?resources|tests?)/.*'))
|
|
140
141
|
|
|
141
142
|
.addOption(new Option('--debug-probe-only', DEBUG_OPTION, boolean).hideHelp())
|
|
142
143
|
.addOption(new Option('--debug-keep-browser-open', DEBUG_OPTION, boolean).hideHelp())
|
package/src/tools.js
CHANGED
|
@@ -6,6 +6,7 @@ const { createHash } = require('crypto')
|
|
|
6
6
|
const { createWriteStream } = require('fs')
|
|
7
7
|
const http = require('http')
|
|
8
8
|
const https = require('https')
|
|
9
|
+
const { unlink } = require('fs/promises')
|
|
9
10
|
|
|
10
11
|
const recursive = { recursive: true }
|
|
11
12
|
|
|
@@ -136,7 +137,13 @@ async function download (url, filename) {
|
|
|
136
137
|
await mkdir(dirname(filename), recursive)
|
|
137
138
|
const output = createWriteStream(filename)
|
|
138
139
|
const { promise, resolve, reject } = allocPromise()
|
|
139
|
-
const request = protocol.request(options, response => {
|
|
140
|
+
const request = protocol.request(options, async response => {
|
|
141
|
+
if (response.statusCode !== 200) {
|
|
142
|
+
reject(response.statusCode)
|
|
143
|
+
output.end()
|
|
144
|
+
await unlink(filename)
|
|
145
|
+
return
|
|
146
|
+
}
|
|
140
147
|
response.on('error', reject)
|
|
141
148
|
response.on('end', resolve)
|
|
142
149
|
response.pipe(output)
|
package/src/ui5.js
CHANGED
package/src/unhandled.js
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = job => {
|
|
|
23
23
|
getOutput(job).unhandled()
|
|
24
24
|
outputUnhandled = false
|
|
25
25
|
}
|
|
26
|
-
writeFile(unhandled, `${extractPageUrl(headers)} ${status} ${method} ${url}\n`, {
|
|
26
|
+
writeFile(unhandled, `${extractPageUrl(headers) || headers.referer} ${status} ${method} ${url}\n`, {
|
|
27
27
|
flag: 'a'
|
|
28
28
|
}, noop)
|
|
29
29
|
return status
|