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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui5-test-runner",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "files": [
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
- console.log('download', url)
165
- await download(origin + url, sourcePath)
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)
@@ -39,6 +39,8 @@ async function main () {
39
39
  >`)
40
40
  if (test.skip) {
41
41
  o(' <skipped></skipped>')
42
+ } else if (!test.report) {
43
+ o(' <skipped>(no report found)</skipped>')
42
44
  } else if (test.report.failed) {
43
45
  test.logs
44
46
  .filter(({ result }) => !result)
@@ -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
- capabilities: {
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: '.png',
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 testing
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('webapp/.*'))
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
@@ -7,7 +7,7 @@ const { capture } = require('reserve')
7
7
  const { getOutput } = require('./output')
8
8
 
9
9
  module.exports = job => {
10
- if (job.mode === 'url') {
10
+ if (job.noUi5) {
11
11
  return []
12
12
  }
13
13
 
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