ui5-test-runner 4.1.1 โ†’ 4.2.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": "4.1.1",
3
+ "version": "4.2.1",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -78,7 +78,7 @@
78
78
  "standard": "^17.1.0",
79
79
  "start-server-and-test": "^2.0.3",
80
80
  "typescript": "^5.3.3",
81
- "ui5-tooling-transpile": "^3.3.4"
81
+ "ui5-tooling-transpile": "^3.3.5"
82
82
  },
83
83
  "optionalDependencies": {
84
84
  "fsevents": "^2.3.3"
@@ -2,9 +2,11 @@
2
2
 
3
3
  const { stop } = require('./browsers')
4
4
  const { URL } = require('url')
5
+ const { getOutput } = require('./output')
5
6
 
6
7
  module.exports = {
7
8
  async addTestPages (job, url, pages) {
9
+ getOutput(job).debug('probe', `addTestPages from ${url}`, pages)
8
10
  let testPageUrls
9
11
  pages = pages.map(relativeUrl => {
10
12
  const absoluteUrl = new URL(relativeUrl, url)
package/src/job-mode.js CHANGED
@@ -29,7 +29,8 @@ function buildAndCheckMode (job) {
29
29
  'pageTimeout',
30
30
  'browserCloseTimeout',
31
31
  'failFast',
32
- 'keepAlive'
32
+ 'keepAlive',
33
+ 'alternateNpmPath'
33
34
  ])
34
35
  return 'capabilities'
35
36
  }
package/src/job.js CHANGED
@@ -102,6 +102,7 @@ function getCommand (cwd) {
102
102
  .option('-p, --parallel <count>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Number of parallel tests executions', 2)
103
103
  .option('-b, --browser <command>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Browser instantiation command (relative to cwd or use $/ for provided ones)', '$/puppeteer.js')
104
104
  .option('--browser-args <argument...>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Browser instantiation command parameters (use -- instead)')
105
+ .option('--alternate-npm-path <path>', '[๐Ÿ’ป๐Ÿ”—] Alternate NPM path to look for packages (priority: local, alternate, global)')
105
106
  .option('--no-npm-install', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Prevent any NPM install (execution may fail if a dependency is missing)')
106
107
  .option('-bt, --browser-close-timeout <timeout>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Maximum waiting time for browser close', timeout, 2000)
107
108
  .option('-br, --browser-retry <count>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Browser instantiation retries : if the command fails unexpectedly, it is re-executed (0 means no retry)', 1)
@@ -111,6 +112,7 @@ function getCommand (cwd) {
111
112
  .option('--webapp <path>', '[๐Ÿ’ป๐Ÿ”—] Base folder of the web application (relative to cwd)', 'webapp')
112
113
  .option('-pf, --page-filter <regexp>', '[๐Ÿ’ป๐Ÿ”—] Filter out pages not matching the regexp')
113
114
  .option('-pp, --page-params <params>', '[๐Ÿ’ป๐Ÿ”—] Add parameters to page URL')
115
+ .option('--page-close-timeout <timeout>', '[๐Ÿ’ป๐Ÿ”—] Maximum waiting time for page close', timeout, 250)
114
116
  .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)
115
117
  .option('--screenshot [flag]', '[๐Ÿ’ป๐Ÿ”—] Take screenshots during the tests execution (if supported by the browser)', boolean, true)
116
118
  .option('--no-screenshot', '[๐Ÿ’ป๐Ÿ”—] Disable screenshots')
@@ -224,6 +226,9 @@ function finalize (job) {
224
226
  if (job.cache) {
225
227
  updateToAbsolute('cache')
226
228
  }
229
+ if (job.alternateNpmPath) {
230
+ checkAccess({ path: job.alternateNpmPath, label: 'Alternate NPM path' })
231
+ }
227
232
  job.mode = buildAndCheckMode(job)
228
233
  if (job.mode === 'legacy') {
229
234
  checkAccess({ path: job.webapp, label: 'webapp folder' })
package/src/npm.js CHANGED
@@ -41,6 +41,38 @@ function resolveDependencyPath (name) {
41
41
  }
42
42
  }
43
43
 
44
+ async function findDependencyPath (job, name) {
45
+ if (!localRoot) {
46
+ [localRoot, globalRoot] = await Promise.all([
47
+ npm(job, 'root'),
48
+ npm(job, 'root', '--global')
49
+ ])
50
+ }
51
+ const localPath = join(localRoot, name)
52
+ if (await folderExists(localPath)) {
53
+ return [localPath, false]
54
+ }
55
+ if (job.alternateNpmPath) {
56
+ const alternatePath = join(job.alternateNpmPath, name)
57
+ if (await folderExists(alternatePath)) {
58
+ return [alternatePath, false]
59
+ }
60
+ }
61
+ const globalPath = join(globalRoot, name)
62
+ let justInstalled = false
63
+ if (!await folderExists(globalPath)) {
64
+ if (!job.npmInstall) {
65
+ throw UTRError.NPM_DEPENDENCY_NOT_FOUND(name)
66
+ }
67
+ const previousStatus = job.status
68
+ job.status = `Installing ${name}...`
69
+ await npm(job, 'install', name, '-g')
70
+ justInstalled = true
71
+ job.status = previousStatus
72
+ }
73
+ return [globalPath, justInstalled]
74
+ }
75
+
44
76
  module.exports = {
45
77
  resolveDependencyPath,
46
78
 
@@ -52,29 +84,7 @@ module.exports = {
52
84
  } catch (e) {
53
85
  }
54
86
  if (!modulePath) {
55
- if (!localRoot) {
56
- [localRoot, globalRoot] = await Promise.all([
57
- npm(job, 'root'),
58
- npm(job, 'root', '--global')
59
- ])
60
- }
61
- const localPath = join(localRoot, name)
62
- if (await folderExists(localPath)) {
63
- modulePath = localPath
64
- } else {
65
- const globalPath = join(globalRoot, name)
66
- if (!await folderExists(globalPath)) {
67
- if (!job.npmInstall) {
68
- throw UTRError.NPM_DEPENDENCY_NOT_FOUND(name)
69
- }
70
- const previousStatus = job.status
71
- job.status = `Installing ${name}...`
72
- await npm(job, 'install', name, '-g')
73
- justInstalled = true
74
- job.status = previousStatus
75
- }
76
- modulePath = globalPath
77
- }
87
+ [modulePath, justInstalled] = await findDependencyPath(job, name)
78
88
  }
79
89
  const output = getOutput(job)
80
90
  const installedPackage = require(join(modulePath, 'package.json'))
package/src/output.js CHANGED
@@ -250,8 +250,9 @@ function build (job) {
250
250
  log(job, p80()`Server running at ${pad.lt(url)}`)
251
251
  },
252
252
 
253
- debug: wrap((module, ...args) => {
254
- if (job.debugVerbose && job.debugVerbose.includes(module)) {
253
+ debug: wrap((moduleSpecifier, ...args) => {
254
+ const [mainModule] = moduleSpecifier.split('/')
255
+ if (job.debugVerbose && (job.debugVerbose.includes(moduleSpecifier) || job.debugVerbose.includes(mainModule))) {
255
256
  console.log(`๐Ÿž${module}`, ...args)
256
257
  output(job, `๐Ÿž${module}`, ...args)
257
258
  }
@@ -5,7 +5,9 @@ const { collect } = require('./coverage')
5
5
  const { UTRError } = require('./error')
6
6
  const { getOutput } = require('./output')
7
7
  const { basename } = require('path')
8
- const { filename, stripUrlHash } = require('./tools')
8
+ const { filename, stripUrlHash, allocPromise } = require('./tools')
9
+ const $doneResolve = Symbol('doneResolve')
10
+ const $doneTimeout = Symbol('doneTimeout')
9
11
 
10
12
  function error (job, url, details = '') {
11
13
  stop(job, url)
@@ -73,27 +75,33 @@ async function done (job, urlWithHash, report) {
73
75
  if (page.count === 0) {
74
76
  return // wait
75
77
  }
76
- if (job.browserCapabilities.screenshot) {
77
- try {
78
- await screenshot(job, url, 'done')
79
- } catch (error) {
80
- getOutput(job).genericError(error, url)
78
+ const { promise, resolve } = allocPromise()
79
+ page[$doneResolve] = resolve
80
+ page[$doneTimeout] = setTimeout(async () => {
81
+ if (job.browserCapabilities.screenshot) {
82
+ try {
83
+ await screenshot(job, url, 'done')
84
+ } catch (error) {
85
+ getOutput(job).genericError(error, url)
86
+ }
81
87
  }
82
- }
83
- page.end = new Date()
84
- if (report.__coverage__) {
85
- await collect(job, url, report.__coverage__)
86
- delete report.__coverage__
87
- }
88
- page.report = report
89
- stop(job, url)
88
+ page.end = new Date()
89
+ if (report.__coverage__) {
90
+ await collect(job, url, report.__coverage__)
91
+ delete report.__coverage__
92
+ }
93
+ page.report = report
94
+ stop(job, url)
95
+ resolve()
96
+ }, job.pageCloseTimeout)
97
+ return promise
90
98
  }
91
99
 
92
100
  module.exports = {
93
101
  get,
94
102
 
95
103
  async begin (job, urlWithHash, details) {
96
- getOutput(job).debug('qunit', 'begin', urlWithHash, details)
104
+ getOutput(job).debug('qunit/begin', 'begin', urlWithHash, details)
97
105
  const { isOpa, totalTests, modules } = details
98
106
  const url = stripUrlHash(urlWithHash)
99
107
  if (!job.qunitPages) {
@@ -112,13 +120,18 @@ module.exports = {
112
120
  },
113
121
 
114
122
  async testStart (job, urlWithHash, details) {
115
- getOutput(job).debug('qunit', 'testStart', urlWithHash, details)
116
- const { test } = get(job, urlWithHash, details)
123
+ getOutput(job).debug('qunit/testStart', 'testStart', urlWithHash, details)
124
+ const { page, test } = get(job, urlWithHash, details)
125
+ const { [$doneTimeout]: doneTimeout, [$doneResolve]: doneResolve } = page
126
+ if (doneTimeout) {
127
+ clearTimeout(doneTimeout)
128
+ doneResolve()
129
+ }
117
130
  test.start = new Date()
118
131
  },
119
132
 
120
133
  async log (job, urlWithHash, details) {
121
- getOutput(job).debug('qunit', 'log', urlWithHash, details)
134
+ getOutput(job).debug('qunit/log', 'log', urlWithHash, details)
122
135
  const { url, page, test } = get(job, urlWithHash, details)
123
136
  const { isOpa, modules, module, name, testId, ...log } = details
124
137
  if (!test) {
@@ -139,7 +152,7 @@ module.exports = {
139
152
  },
140
153
 
141
154
  async testDone (job, urlWithHash, details) {
142
- getOutput(job).debug('qunit', 'testDone', urlWithHash, details)
155
+ getOutput(job).debug('qunit/testDone', 'testDone', urlWithHash, details)
143
156
  const { name, module, testId, assertions, ...report } = details
144
157
  const { failed } = report
145
158
  const { url, page, test } = get(job, urlWithHash, { testId })
@@ -180,5 +193,8 @@ module.exports = {
180
193
  }
181
194
  },
182
195
 
183
- done
196
+ async done (job, urlWithHash, report) {
197
+ getOutput(job).debug('qunit/done', 'done', urlWithHash, report)
198
+ await done(job, urlWithHash, report)
199
+ }
184
200
  }