ui5-test-runner 5.9.1 → 5.10.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 +3 -4
- package/jest.config.json +1 -0
- package/package.json +9 -9
- package/src/browsers.js +5 -1
- package/src/clean.js +5 -12
- package/src/cors.js +2 -2
- package/src/coverage.js +1 -1
- package/src/defaults/puppeteer.js +11 -0
- package/src/defaults/report/decompress.js +19 -0
- package/src/defaults/report.js +27 -7
- package/src/defaults/scan-ui5.js +7 -1
- package/src/endpoints.js +32 -0
- package/src/handle.js +43 -0
- package/src/inject/jest2qunit.js +289 -0
- package/src/inject/post.js +42 -7
- package/src/inject/qunit-hooks.js +22 -15
- package/src/job.js +15 -4
- package/src/npm.js +3 -1
- package/src/output.js +55 -3
- package/src/reserve.js +1 -1
- package/src/start.js +58 -20
- package/src/tests.js +50 -8
- package/src/ui5.js +105 -102
package/src/ui5.js
CHANGED
|
@@ -16,6 +16,109 @@ const buildCacheBase = job => {
|
|
|
16
16
|
return join(job.cache || '', hostName.replace(':', '_'), version || '')
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const ui5mappings = job => {
|
|
20
|
+
const cacheBase = buildCacheBase(job)
|
|
21
|
+
const match = /\/((?:test-)?resources\/.*)/
|
|
22
|
+
const ifCacheEnabled = (request, url, match) => job.cache
|
|
23
|
+
const uncachable = {}
|
|
24
|
+
const cachingInProgress = {}
|
|
25
|
+
|
|
26
|
+
const mappings = [{
|
|
27
|
+
/* 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
|
+
*/
|
|
31
|
+
match,
|
|
32
|
+
'if-match': ifCacheEnabled,
|
|
33
|
+
custom: async (request, response, path) => {
|
|
34
|
+
if (uncachable[path]) {
|
|
35
|
+
response.writeHead(404)
|
|
36
|
+
response.end()
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
const cachingPromise = cachingInProgress[path]
|
|
40
|
+
/* istanbul ignore next */ // Hard to reproduce
|
|
41
|
+
if (cachingPromise) {
|
|
42
|
+
await cachingPromise
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
// UI5 from cache
|
|
47
|
+
match,
|
|
48
|
+
'if-match': ifCacheEnabled,
|
|
49
|
+
cwd: cacheBase,
|
|
50
|
+
file: '$1',
|
|
51
|
+
static: !job.debugDevMode
|
|
52
|
+
}, {
|
|
53
|
+
// UI5 caching
|
|
54
|
+
method: 'GET',
|
|
55
|
+
match,
|
|
56
|
+
'if-match': ifCacheEnabled,
|
|
57
|
+
custom: async (request, response, path) => {
|
|
58
|
+
const filePath = /([^?#]+)/.exec(unescape(path))[1] // filter URL parameters & hash (assuming resources are static)
|
|
59
|
+
const cachePath = join(cacheBase, filePath)
|
|
60
|
+
const cacheFolder = dirname(cachePath)
|
|
61
|
+
await mkdir(cacheFolder, { recursive: true })
|
|
62
|
+
if (cachingInProgress[path]) {
|
|
63
|
+
return request.url // loop back to use cached result
|
|
64
|
+
}
|
|
65
|
+
const file = createWriteStream(cachePath)
|
|
66
|
+
cachingInProgress[path] = capture(response, file)
|
|
67
|
+
.catch(reason => {
|
|
68
|
+
file.end()
|
|
69
|
+
uncachable[path] = true
|
|
70
|
+
if (response.statusCode !== 404) {
|
|
71
|
+
getOutput(job).failedToCacheUI5resource(path, response.statusCode)
|
|
72
|
+
}
|
|
73
|
+
return unlink(cachePath)
|
|
74
|
+
})
|
|
75
|
+
.then(() => {
|
|
76
|
+
delete cachingInProgress[path]
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
// UI5 from url
|
|
81
|
+
method: ['GET', 'HEAD'],
|
|
82
|
+
match,
|
|
83
|
+
url: `${job.ui5}/$1`,
|
|
84
|
+
'ignore-unverifiable-certificate': true
|
|
85
|
+
}]
|
|
86
|
+
|
|
87
|
+
for (let { relative, source } of job.libs) {
|
|
88
|
+
if (source.endsWith('/') || source.endsWith('\\')) {
|
|
89
|
+
source = source.substring(0, source.length - 1)
|
|
90
|
+
}
|
|
91
|
+
const relativeUrl = relative.replace(/\//g, '\\/')
|
|
92
|
+
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
|
+
})
|
|
99
|
+
} else {
|
|
100
|
+
mappings.unshift({
|
|
101
|
+
match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
|
|
102
|
+
cwd: source,
|
|
103
|
+
file: '$1',
|
|
104
|
+
static: !job.watch && !job.debugDevMode
|
|
105
|
+
}, {
|
|
106
|
+
match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
|
|
107
|
+
custom: (request, response, $1) => {
|
|
108
|
+
if ($1 === undefined) {
|
|
109
|
+
getOutput(job).debug('libs', `Unable to map ${relative} : $1 is undefined`)
|
|
110
|
+
} else {
|
|
111
|
+
getOutput(job).debug('libs', `Unable to map ${relative}/${$1} to ${join(source, $1)}`)
|
|
112
|
+
}
|
|
113
|
+
return 404
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return mappings
|
|
120
|
+
}
|
|
121
|
+
|
|
19
122
|
module.exports = {
|
|
20
123
|
preload: async job => {
|
|
21
124
|
const cacheBase = buildCacheBase(job)
|
|
@@ -57,110 +160,10 @@ module.exports = {
|
|
|
57
160
|
progress.done()
|
|
58
161
|
},
|
|
59
162
|
|
|
60
|
-
mappings: job => {
|
|
163
|
+
mappings: async job => {
|
|
61
164
|
if (job.disableUi5) {
|
|
62
165
|
return []
|
|
63
166
|
}
|
|
64
|
-
|
|
65
|
-
const cacheBase = buildCacheBase(job)
|
|
66
|
-
const match = /\/((?:test-)?resources\/.*)/
|
|
67
|
-
const ifCacheEnabled = (request, url, match) => job.cache
|
|
68
|
-
const uncachable = {}
|
|
69
|
-
const cachingInProgress = {}
|
|
70
|
-
|
|
71
|
-
const mappings = [{
|
|
72
|
-
/* Prevent caching issues :
|
|
73
|
-
* - Caching was not possible (99% URL does not exist)
|
|
74
|
-
* - Caching is in progress (must wait for the end of the writing stream)
|
|
75
|
-
*/
|
|
76
|
-
match,
|
|
77
|
-
'if-match': ifCacheEnabled,
|
|
78
|
-
custom: async (request, response, path) => {
|
|
79
|
-
if (uncachable[path]) {
|
|
80
|
-
response.writeHead(404)
|
|
81
|
-
response.end()
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
const cachingPromise = cachingInProgress[path]
|
|
85
|
-
/* istanbul ignore next */ // Hard to reproduce
|
|
86
|
-
if (cachingPromise) {
|
|
87
|
-
await cachingPromise
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
// UI5 from cache
|
|
92
|
-
match,
|
|
93
|
-
'if-match': ifCacheEnabled,
|
|
94
|
-
cwd: cacheBase,
|
|
95
|
-
file: '$1',
|
|
96
|
-
static: !job.debugDevMode
|
|
97
|
-
}, {
|
|
98
|
-
// UI5 caching
|
|
99
|
-
method: 'GET',
|
|
100
|
-
match,
|
|
101
|
-
'if-match': ifCacheEnabled,
|
|
102
|
-
custom: async (request, response, path) => {
|
|
103
|
-
const filePath = /([^?#]+)/.exec(unescape(path))[1] // filter URL parameters & hash (assuming resources are static)
|
|
104
|
-
const cachePath = join(cacheBase, filePath)
|
|
105
|
-
const cacheFolder = dirname(cachePath)
|
|
106
|
-
await mkdir(cacheFolder, { recursive: true })
|
|
107
|
-
if (cachingInProgress[path]) {
|
|
108
|
-
return request.url // loop back to use cached result
|
|
109
|
-
}
|
|
110
|
-
const file = createWriteStream(cachePath)
|
|
111
|
-
cachingInProgress[path] = capture(response, file)
|
|
112
|
-
.catch(reason => {
|
|
113
|
-
file.end()
|
|
114
|
-
uncachable[path] = true
|
|
115
|
-
if (response.statusCode !== 404) {
|
|
116
|
-
getOutput(job).failedToCacheUI5resource(path, response.statusCode)
|
|
117
|
-
}
|
|
118
|
-
return unlink(cachePath)
|
|
119
|
-
})
|
|
120
|
-
.then(() => {
|
|
121
|
-
delete cachingInProgress[path]
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
// UI5 from url
|
|
126
|
-
method: ['GET', 'HEAD'],
|
|
127
|
-
match,
|
|
128
|
-
url: `${job.ui5}/$1`,
|
|
129
|
-
'ignore-unverifiable-certificate': true
|
|
130
|
-
}]
|
|
131
|
-
|
|
132
|
-
for (let { relative, source } of job.libs) {
|
|
133
|
-
if (source.endsWith('/') || source.endsWith('\\')) {
|
|
134
|
-
source = source.substring(0, source.length - 1)
|
|
135
|
-
}
|
|
136
|
-
const relativeUrl = relative.replace(/\//g, '\\/')
|
|
137
|
-
if (source.startsWith(job.webapp)) {
|
|
138
|
-
const relativeAbsoluteUrl = '/' + relativePath(job.webapp, source).replace(/\\/g, '/')
|
|
139
|
-
getOutput(job).debug('libs', `${relative} maps to webapp sub directory, use internal redirection to ${relativeAbsoluteUrl}`)
|
|
140
|
-
mappings.unshift({
|
|
141
|
-
match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
|
|
142
|
-
custom: (request, response, $1) => `${relativeAbsoluteUrl}${$1}`
|
|
143
|
-
})
|
|
144
|
-
} else {
|
|
145
|
-
mappings.unshift({
|
|
146
|
-
match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
|
|
147
|
-
cwd: source,
|
|
148
|
-
file: '$1',
|
|
149
|
-
static: !job.watch && !job.debugDevMode
|
|
150
|
-
}, {
|
|
151
|
-
match: new RegExp(`\\/resources\\/${relativeUrl}(.*)`),
|
|
152
|
-
custom: (request, response, $1) => {
|
|
153
|
-
if ($1 === undefined) {
|
|
154
|
-
getOutput(job).debug('libs', `Unable to map ${relative} : $1 is undefined`)
|
|
155
|
-
} else {
|
|
156
|
-
getOutput(job).debug('libs', `Unable to map ${relative}/${$1} to ${join(source, $1)}`)
|
|
157
|
-
}
|
|
158
|
-
return 404
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return mappings
|
|
167
|
+
return ui5mappings(job)
|
|
165
168
|
}
|
|
166
169
|
}
|