ui5-test-runner 5.11.1 → 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/.releaserc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "branches": [
3
+ { "name": "5.x.y", "channel": "latest" }
4
+ ]
5
+ }
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.1",
3
+ "version": "5.12.0",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -57,16 +57,17 @@
57
57
  "reserve": "2.3.4"
58
58
  },
59
59
  "devDependencies": {
60
- "@openui5/types": "^1.142.0",
60
+ "@openui5/types": "^1.143.0",
61
61
  "@semantic-release/npm": "^13.1.2",
62
- "@ui5/cli": "^4.0.35",
62
+ "@ui5/cli": "^4.0.37",
63
63
  "@ui5/middleware-code-coverage": "^2.0.2",
64
+ "baseline-browser-mapping": "^2.8.32",
64
65
  "dotenv": "^16.5.0",
65
66
  "jest": "^29.7.0",
66
67
  "nock": "^14.0.10",
67
68
  "npm-check-updates": "^18.3.0",
68
69
  "nyc": "^17.1.0",
69
- "rimraf": "^6.1.0",
70
+ "rimraf": "^6.1.2",
70
71
  "semantic-release": "^25.0.2",
71
72
  "standard": "^17.1.2",
72
73
  "typescript": "^5.9.3",
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
@@ -16,18 +16,39 @@ const buildCacheBase = job => {
16
16
  return join(job.cache || '', hostName.replace(':', '_'), version || '')
17
17
  }
18
18
 
19
- const ui5mappings = job => {
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
- const ifCacheEnabled = (request, url, match) => job.cache
23
+ const ifCacheEnabled = () => job.cache
23
24
  const uncachable = {}
24
25
  const cachingInProgress = {}
25
26
 
27
+ let { ui5 } = job
28
+ if (!ui5.endsWith('/')) {
29
+ ui5 += '/'
30
+ }
31
+ const mappingUrl = new URL('$1', ui5).toString()
32
+
33
+ const inJest = typeof jest !== 'undefined'
34
+ /* istanbul ignore next */
35
+ if (!inJest) {
36
+ const versionUrl = mappingUrl.replace('$1', 'resources/sap-ui-version.json')
37
+ const versionResponse = await fetch(versionUrl)
38
+ if (versionResponse.status !== 200) {
39
+ output.log('Unable to fetch UI5 version: ' + versionResponse.status + ' ' + versionResponse.statusText)
40
+ throw new Error('Unable to fetch UI5 version')
41
+ }
42
+ const version = await versionResponse.json()
43
+ const { version: coreVersion } = version.libraries.find(({ name }) => name === 'sap.ui.core')
44
+ output.log('UI5 version used by the local server: ' + coreVersion)
45
+ }
46
+
26
47
  const mappings = [{
27
48
  /* Prevent caching issues :
28
- * - Caching was not possible (99% URL does not exist)
29
- * - Caching is in progress (must wait for the end of the writing stream)
30
- */
49
+ * - Caching was not possible (99% URL does not exist)
50
+ * - Caching is in progress (must wait for the end of the writing stream)
51
+ */
31
52
  match,
32
53
  'if-match': ifCacheEnabled,
33
54
  custom: async (request, response, path) => {
@@ -42,15 +63,13 @@ const ui5mappings = job => {
42
63
  await cachingPromise
43
64
  }
44
65
  }
45
- }, {
46
- // UI5 from cache
66
+ }, { // UI5 from cache
47
67
  match,
48
68
  'if-match': ifCacheEnabled,
49
69
  cwd: cacheBase,
50
70
  file: '$1',
51
71
  static: !job.debugDevMode
52
- }, {
53
- // UI5 caching
72
+ }, { // UI5 caching
54
73
  method: 'GET',
55
74
  match,
56
75
  'if-match': ifCacheEnabled,
@@ -68,7 +87,7 @@ const ui5mappings = job => {
68
87
  file.end()
69
88
  uncachable[path] = true
70
89
  if (response.statusCode !== 404) {
71
- getOutput(job).failedToCacheUI5resource(path, response.statusCode)
90
+ output.failedToCacheUI5resource(path, response.statusCode)
72
91
  }
73
92
  return unlink(cachePath)
74
93
  })
@@ -76,11 +95,10 @@ const ui5mappings = job => {
76
95
  delete cachingInProgress[path]
77
96
  })
78
97
  }
79
- }, {
80
- // UI5 from url
98
+ }, { // UI5 from url
81
99
  method: ['GET', 'HEAD'],
82
100
  match,
83
- url: new URL('$1', job.ui5).toString(),
101
+ url: mappingUrl,
84
102
  'ignore-unverifiable-certificate': true
85
103
  }]
86
104
 
@@ -90,12 +108,24 @@ const ui5mappings = job => {
90
108
  }
91
109
  const relativeUrl = relative.replace(/\//g, '\\/')
92
110
  if (source.startsWith(job.webapp)) {
93
- const relativeAbsoluteUrl = '/' + relativePath(job.webapp, source).replace(/\\/g, '/')
94
- getOutput(job).debug('libs', `${relative} maps to webapp sub directory, use internal redirection to ${relativeAbsoluteUrl}`)
95
- mappings.unshift({
96
- match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
97
- custom: (request, response, $1) => `${relativeAbsoluteUrl}${$1}`
98
- })
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
+ }
99
129
  } else {
100
130
  mappings.unshift({
101
131
  match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
@@ -106,9 +136,9 @@ const ui5mappings = job => {
106
136
  match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
107
137
  custom: (request, response, $1) => {
108
138
  if ($1 === undefined) {
109
- getOutput(job).debug('libs', `Unable to map ${relative} : $1 is undefined`)
139
+ output.debug('libs', `Unable to map ${relative} : $1 is undefined`)
110
140
  } else {
111
- 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)}`)
112
142
  }
113
143
  return 404
114
144
  }