ui5-test-runner 5.11.2 → 5.12.0

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/index.js CHANGED
@@ -58,14 +58,14 @@ async function main () {
58
58
  }
59
59
  output.reportOnJobProgress()
60
60
  checkLatest(job, name, version)
61
- if (job.mode === 'capabilities') {
62
- return capabilities(job)
63
- }
64
61
  if (job.if && !executeIf(job)) {
65
62
  output.skipIf()
66
63
  output.stop()
67
64
  return
68
65
  }
66
+ if (job.mode === 'capabilities') {
67
+ return capabilities(job)
68
+ }
69
69
 
70
70
  let startedCommand
71
71
  if (job.startCommand) {
package/jest.config.json CHANGED
@@ -5,7 +5,8 @@
5
5
  ],
6
6
  "testPathIgnorePatterns": [
7
7
  "/node_modules/",
8
- "/capabilities/"
8
+ "/capabilities/",
9
+ "/e2e/"
9
10
  ],
10
11
  "collectCoverage": true,
11
12
  "collectCoverageFrom": [
@@ -16,6 +17,7 @@
16
17
  "\\.spec\\.js",
17
18
  "output\\.js",
18
19
  "handle\\.js",
20
+ "coverage\\.js",
19
21
  "b\\capabilities\\b"
20
22
  ],
21
23
  "coverageThreshold": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui5-test-runner",
3
- "version": "5.11.2",
3
+ "version": "5.12.0",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/job-mode.js CHANGED
@@ -41,16 +41,13 @@ function buildAndCheckMode (job) {
41
41
  'batchMode',
42
42
  'batchId',
43
43
  'batchLabel',
44
- 'ci'
44
+ 'ci',
45
+ 'if'
45
46
  ])
46
47
  return 'capabilities'
47
48
  }
48
49
  if (job.url && job.url.length) {
49
50
  check(job, undefined, [
50
- 'ui5',
51
- 'libs',
52
- 'mappings',
53
- 'cache',
54
51
  'testsuite'
55
52
  ])
56
53
  return 'url'
package/src/job.js CHANGED
@@ -159,7 +159,7 @@ function getCommand (cwd) {
159
159
  // Specific to legacy (and might be used with url if pointing to local project)
160
160
  .option('--ui5 <url>', '[💻📡] UI5 url', url, 'https://ui5.sap.com')
161
161
  .option('--disable-ui5 [flag]', '[💻📡] Disable UI5 mapping (also disable libs)', boolean, false)
162
- .option('--libs <lib...>', '[💻📡] Library mapping (<relative>=<path> or <path>)', arrayOf(lib))
162
+ .option('--libs <lib...>', '[💻📡] Library mapping (<relative>=<path> or <path>), use *=webapp/resources to map resources sub folder', arrayOf(lib))
163
163
  .option('--mappings <mapping...>', '[💻📡] Custom mapping (<match>=<file|url>(<config>))', arrayOf(mapping))
164
164
  .option('--cache <path>', '[💻📡] Cache UI5 resources locally in the given folder (empty to disable)')
165
165
  .option('--preload <library...>', '[💻📡] Preload UI5 libraries in the cache folder (only if --cache is used)', arrayOf(string))
package/src/start.js CHANGED
@@ -127,6 +127,7 @@ async function start (job) {
127
127
  }
128
128
  if (!startProcessExited) {
129
129
  output.failedToTerminateStartCommand()
130
+ startProcess.unref() // the runner shall not be blocked by this process
130
131
  startProcess.kill()
131
132
  }
132
133
  }
package/src/ui5.js CHANGED
@@ -17,6 +17,7 @@ const buildCacheBase = job => {
17
17
  }
18
18
 
19
19
  const ui5mappings = async job => {
20
+ const output = getOutput(job)
20
21
  const cacheBase = buildCacheBase(job)
21
22
  const match = /\/((?:test-)?resources\/.*)/ // Captured value never starts with /
22
23
  const ifCacheEnabled = () => job.cache
@@ -35,12 +36,12 @@ const ui5mappings = async job => {
35
36
  const versionUrl = mappingUrl.replace('$1', 'resources/sap-ui-version.json')
36
37
  const versionResponse = await fetch(versionUrl)
37
38
  if (versionResponse.status !== 200) {
38
- getOutput(job).log('Unable to fetch UI5 version: ' + versionResponse.status + ' ' + versionResponse.statusText)
39
+ output.log('Unable to fetch UI5 version: ' + versionResponse.status + ' ' + versionResponse.statusText)
39
40
  throw new Error('Unable to fetch UI5 version')
40
41
  }
41
42
  const version = await versionResponse.json()
42
43
  const { version: coreVersion } = version.libraries.find(({ name }) => name === 'sap.ui.core')
43
- getOutput(job).log('UI5 version used by the local server: ' + coreVersion)
44
+ output.log('UI5 version used by the local server: ' + coreVersion)
44
45
  }
45
46
 
46
47
  const mappings = [{
@@ -86,7 +87,7 @@ const ui5mappings = async job => {
86
87
  file.end()
87
88
  uncachable[path] = true
88
89
  if (response.statusCode !== 404) {
89
- getOutput(job).failedToCacheUI5resource(path, response.statusCode)
90
+ output.failedToCacheUI5resource(path, response.statusCode)
90
91
  }
91
92
  return unlink(cachePath)
92
93
  })
@@ -107,12 +108,24 @@ const ui5mappings = async job => {
107
108
  }
108
109
  const relativeUrl = relative.replace(/\//g, '\\/')
109
110
  if (source.startsWith(job.webapp)) {
110
- const relativeAbsoluteUrl = '/' + relativePath(job.webapp, source).replace(/\\/g, '/')
111
- getOutput(job).debug('libs', `${relative} maps to webapp sub directory, use internal redirection to ${relativeAbsoluteUrl}`)
112
- mappings.unshift({
113
- match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
114
- custom: (request, response, $1) => `${relativeAbsoluteUrl}${$1}`
115
- })
111
+ if (relative === '*') {
112
+ // Special handling to support webapp/resources folder (/!\ coverage won't be extracted for those files)
113
+ output.debug('libs', '* map to webapp sub directory (expected resources), use file access')
114
+ mappings.unshift({
115
+ match: /\/resources\/(.*)/,
116
+ cwd: source,
117
+ file: '$1',
118
+ static: !job.watch && !job.debugDevMode
119
+ })
120
+ } else {
121
+ // Use redirection to support local coverage instrumentation
122
+ const relativeAbsoluteUrl = '/' + relativePath(job.webapp, source).replace(/\\/g, '/')
123
+ output.debug('libs', `${relative} maps to webapp sub directory, use internal redirection to ${relativeAbsoluteUrl}`)
124
+ mappings.unshift({
125
+ match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
126
+ custom: (request, response, $1) => `${relativeAbsoluteUrl}${$1}`
127
+ })
128
+ }
116
129
  } else {
117
130
  mappings.unshift({
118
131
  match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
@@ -123,9 +136,9 @@ const ui5mappings = async job => {
123
136
  match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
124
137
  custom: (request, response, $1) => {
125
138
  if ($1 === undefined) {
126
- getOutput(job).debug('libs', `Unable to map ${relative} : $1 is undefined`)
139
+ output.debug('libs', `Unable to map ${relative} : $1 is undefined`)
127
140
  } else {
128
- getOutput(job).debug('libs', `Unable to map ${relative}/${$1} to ${join(source, $1)}`)
141
+ output.debug('libs', `Unable to map ${relative}/${$1} to ${join(source, $1)}`)
129
142
  }
130
143
  return 404
131
144
  }