ui5-test-runner 3.3.5 → 4.1.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/README.md +9 -16
- package/package.json +17 -18
- package/src/browsers.js +9 -1
- package/src/capabilities/index.js +6 -6
- package/src/capabilities/tests/screenshot/index.html +13 -3
- package/src/capabilities/tests/screenshot/index.js +11 -5
- package/src/capabilities/tests/traces/index.js +1 -1
- package/src/coverage.js +51 -42
- package/src/defaults/puppeteer.js +10 -20
- package/src/defaults/report/progress.js +11 -0
- package/src/endpoints.js +8 -0
- package/src/get-job-progress.js +9 -0
- package/src/inject/opa-iframe-coverage.js +0 -1
- package/src/inject/post.js +4 -4
- package/src/inject/qunit-hooks.js +18 -2
- package/src/inject/qunit-intercept.js +6 -0
- package/src/inject/ui5-coverage.js +6 -0
- package/src/job-mode.js +0 -1
- package/src/job.js +10 -10
- package/src/options.js +4 -0
- package/src/output.js +56 -24
- package/src/qunit-hooks.js +43 -29
- package/src/symbols.js +2 -1
- package/src/tests.js +6 -1
- package/src/add-test-pages.spec.js +0 -95
- package/src/browser.spec.js +0 -724
- package/src/cors.spec.js +0 -41
- package/src/coverage.spec.js +0 -120
- package/src/csv-reader.spec.js +0 -42
- package/src/csv-writer.spec.js +0 -77
- package/src/error.spec.js +0 -17
- package/src/get-job-progress.spec.js +0 -175
- package/src/inject/post.spec.js +0 -147
- package/src/job.spec.js +0 -418
- package/src/npm.spec.js +0 -98
- package/src/options.spec.js +0 -141
- package/src/qunit-hooks.spec.js +0 -747
- package/src/simulate.spec.js +0 -547
- package/src/timeout.spec.js +0 -39
- package/src/tools.spec.js +0 -90
- package/src/unhandled.spec.js +0 -63
package/src/simulate.spec.js
DELETED
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
const { join, dirname } = require('path')
|
|
2
|
-
const { mock } = require('reserve')
|
|
3
|
-
const jobFactory = require('./job')
|
|
4
|
-
const reserveConfigurationFactory = require('./reserve')
|
|
5
|
-
const { mock: mockChildProcess } = require('child_process')
|
|
6
|
-
const { execute } = require('./tests')
|
|
7
|
-
const nock = require('nock')
|
|
8
|
-
const { readFile, stat, writeFile } = require('fs').promises
|
|
9
|
-
const { cleanDir } = require('./tools')
|
|
10
|
-
const { UTRError } = require('./error')
|
|
11
|
-
const { $browsers } = require('./symbols')
|
|
12
|
-
const { getOutput } = require('./output')
|
|
13
|
-
|
|
14
|
-
describe('simulate', () => {
|
|
15
|
-
const simulatePath = join(__dirname, '../tmp/simulate')
|
|
16
|
-
const cwd = join(__dirname, '../test/project')
|
|
17
|
-
|
|
18
|
-
let job
|
|
19
|
-
let mocked
|
|
20
|
-
let pages = {}
|
|
21
|
-
|
|
22
|
-
beforeAll(() => {
|
|
23
|
-
const nockScope = nock('https://ui5.sap.com/').persist()
|
|
24
|
-
const nockContent = [
|
|
25
|
-
'/resources/sap-ui-core.js',
|
|
26
|
-
'/resources/sap/ui/qunit/qunit-redirect.js',
|
|
27
|
-
'/resources/sap/ui/thirdparty/qunit.js',
|
|
28
|
-
'/resources/sap/ui/thirdparty/qunit-2.js'
|
|
29
|
-
]
|
|
30
|
-
nockContent.forEach(url => {
|
|
31
|
-
nockScope.get(url).reply(200, `/* ${url} */`)
|
|
32
|
-
})
|
|
33
|
-
nockScope.get('/resources/not-found.js').reply(404)
|
|
34
|
-
nockScope.get('/resources/error.js').reply(500)
|
|
35
|
-
return cleanDir(simulatePath)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
async function get (url, referer) {
|
|
39
|
-
return await mocked.request('GET', url, { 'x-page-url': referer })
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function post (url, referer, body) {
|
|
43
|
-
const json = JSON.stringify(body)
|
|
44
|
-
return await mocked.request('POST', url, {
|
|
45
|
-
'x-page-url': referer,
|
|
46
|
-
'content-type': 'application/json',
|
|
47
|
-
'content-length': json.length
|
|
48
|
-
}, json)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function simulateOK (referer, __coverage__ = undefined) {
|
|
52
|
-
await post('/_/QUnit/begin', referer, { totalTests: 1, modules: [{ tests: [{ testId: '1' }] }] })
|
|
53
|
-
await post('/_/QUnit/testDone', referer, { testId: '1', failed: 0, passed: 1 })
|
|
54
|
-
await post('/_/QUnit/done', referer, { failed: 0, __coverage__ })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function setup (name, parameters) {
|
|
58
|
-
mockChildProcess({
|
|
59
|
-
api: 'fork',
|
|
60
|
-
scriptPath: /puppeteer\.js$/,
|
|
61
|
-
exec: async childProcess => {
|
|
62
|
-
const config = JSON.parse((await readFile(childProcess.args[0])).toString())
|
|
63
|
-
const { capabilities, url: referer } = config
|
|
64
|
-
if (typeof capabilities === 'string') {
|
|
65
|
-
await writeFile(capabilities, JSON.stringify({
|
|
66
|
-
console: true,
|
|
67
|
-
scripts: true
|
|
68
|
-
}))
|
|
69
|
-
childProcess.close()
|
|
70
|
-
} else {
|
|
71
|
-
childProcess.on('message.received', message => {
|
|
72
|
-
if (message.command === 'stop') {
|
|
73
|
-
childProcess.close()
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
const pageName = Object.keys(pages).filter(page => referer.endsWith(page))[0]
|
|
77
|
-
if (pageName) {
|
|
78
|
-
await pages[pageName](referer)
|
|
79
|
-
} else {
|
|
80
|
-
console.warn(`Page ${referer} not found`)
|
|
81
|
-
expect(false).toStrictEqual(true)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
close: false
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
mockChildProcess({
|
|
89
|
-
api: 'fork',
|
|
90
|
-
scriptPath: /\breport\.js$/,
|
|
91
|
-
exec: async childProcess => {
|
|
92
|
-
const reportDir = childProcess.args[0]
|
|
93
|
-
await writeFile(join(reportDir, 'report.html'), '<html />')
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
job = jobFactory.fromObject(cwd, {
|
|
98
|
-
reportDir: join(simulatePath, name, 'report'),
|
|
99
|
-
coverageTempDir: join(simulatePath, name, 'coverage/temp'),
|
|
100
|
-
coverageReportDir: join(simulatePath, name, 'coverage/report'),
|
|
101
|
-
coverage: false,
|
|
102
|
-
...parameters
|
|
103
|
-
})
|
|
104
|
-
const configuration = await reserveConfigurationFactory(job)
|
|
105
|
-
mocked = await mock(configuration)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function safeExecute () {
|
|
109
|
-
try {
|
|
110
|
-
getOutput(job).reportOnJobProgress()
|
|
111
|
-
await execute(job)
|
|
112
|
-
} catch (e) {
|
|
113
|
-
if (e instanceof UTRError && e.code === UTRError.BROWSER_FAILED_CODE) {
|
|
114
|
-
const exception = Object.keys(job[$browsers])
|
|
115
|
-
.map(url => job[$browsers][url].childProcess && job[$browsers][url].childProcess.exception)
|
|
116
|
-
.filter(e => !!e)[0]
|
|
117
|
-
throw exception
|
|
118
|
-
}
|
|
119
|
-
throw e
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
describe('mappings', () => {
|
|
124
|
-
beforeAll(async () => {
|
|
125
|
-
await setup('mappings', {
|
|
126
|
-
mappings: [
|
|
127
|
-
'/overridden/resources/(.*)=file(./LICENSE)'
|
|
128
|
-
]
|
|
129
|
-
})
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
const urls = [
|
|
133
|
-
'/webapp/resources/sap-ui-core.js',
|
|
134
|
-
'/resources/sap-ui-core.js',
|
|
135
|
-
'/custom/resources/sap-ui-core.js'
|
|
136
|
-
]
|
|
137
|
-
urls.forEach(url => {
|
|
138
|
-
it(`fetches UI5 resources whichever path is used (${url})`, async () => {
|
|
139
|
-
const response = await get(url, 'test.html')
|
|
140
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
141
|
-
expect(response.toString().includes('/sap-ui-core.js */')).toStrictEqual(true)
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('enables overridding through mappings', async () => {
|
|
146
|
-
const response = await get('/overridden/resources/sap-ui-core.js', 'test.html')
|
|
147
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
148
|
-
expect(response.toString().startsWith('MIT License')).toStrictEqual(true)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
describe('legacy (local project)', () => {
|
|
153
|
-
describe('simple test execution', () => {
|
|
154
|
-
beforeAll(async () => {
|
|
155
|
-
await setup('simple')
|
|
156
|
-
pages = {
|
|
157
|
-
'testsuite.qunit.html': async referer => {
|
|
158
|
-
const response = await get('/resources/sap/ui/qunit/qunit-redirect.js', referer)
|
|
159
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
160
|
-
expect(response.toString().includes('qunit-redirect.js */')).toStrictEqual(false)
|
|
161
|
-
expect(response.toString().includes('addTestPages')).toStrictEqual(true)
|
|
162
|
-
await post('/_/addTestPages', referer, [
|
|
163
|
-
referer.replace('testsuite.qunit.html', 'page1.html'),
|
|
164
|
-
referer.replace('testsuite.qunit.html', 'page2.html')
|
|
165
|
-
])
|
|
166
|
-
},
|
|
167
|
-
'page1.html': async referer => {
|
|
168
|
-
const response = await get('/resources/sap/ui/thirdparty/qunit.js', referer)
|
|
169
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
170
|
-
expect(response.toString().includes('qunit.js */')).toStrictEqual(true)
|
|
171
|
-
expect(response.toString().includes('QUnit/begin')).toStrictEqual(true)
|
|
172
|
-
simulateOK(referer)
|
|
173
|
-
},
|
|
174
|
-
'page2.html': async referer => {
|
|
175
|
-
const response = await get('/resources/sap/ui/thirdparty/qunit-2.js', referer)
|
|
176
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
177
|
-
expect(response.toString().includes('qunit-2.js */')).toStrictEqual(true)
|
|
178
|
-
expect(response.toString().includes('QUnit/begin')).toStrictEqual(true)
|
|
179
|
-
simulateOK(referer)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
await safeExecute()
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
it('succeeded', () => {
|
|
186
|
-
expect(job.failed).toStrictEqual(false)
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
it('provides a progress endpoint', async () => {
|
|
190
|
-
const response = await mocked.request('GET', '/_/progress')
|
|
191
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
192
|
-
const progress = JSON.parse(response.toString())
|
|
193
|
-
expect(Object.keys(progress.qunitPages).length).toStrictEqual(2)
|
|
194
|
-
|
|
195
|
-
const page1 = Object.keys(progress.qunitPages).filter(url => url.endsWith('page1.html'))
|
|
196
|
-
expect(page1).not.toBeUndefined()
|
|
197
|
-
const qunitPage1 = progress.qunitPages[page1]
|
|
198
|
-
expect(qunitPage1).not.toStrictEqual(undefined)
|
|
199
|
-
expect(qunitPage1.failed).toStrictEqual(0)
|
|
200
|
-
expect(qunitPage1.passed).toStrictEqual(1)
|
|
201
|
-
expect(qunitPage1.report).not.toStrictEqual(undefined)
|
|
202
|
-
|
|
203
|
-
const page2 = Object.keys(progress.qunitPages).filter(url => url.endsWith('page2.html'))
|
|
204
|
-
expect(page2).not.toBeUndefined()
|
|
205
|
-
const qunitPage2 = progress.qunitPages[page2]
|
|
206
|
-
expect(qunitPage2).not.toStrictEqual(undefined)
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
it('generates a report', async () => {
|
|
210
|
-
const info = await stat(join(job.reportDir, 'report.html'))
|
|
211
|
-
expect(info.isFile()).toStrictEqual(true)
|
|
212
|
-
expect(info.size).toBeGreaterThan(0)
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
describe('simple test execution (--no-qunit-strict)', () => {
|
|
217
|
-
beforeAll(async () => {
|
|
218
|
-
await setup('simple-early')
|
|
219
|
-
pages = {
|
|
220
|
-
'testsuite.qunit.html': async referer => {
|
|
221
|
-
await post('/_/addTestPages', referer, [
|
|
222
|
-
referer.replace('testsuite.qunit.html', 'page1.html')
|
|
223
|
-
])
|
|
224
|
-
},
|
|
225
|
-
'page1.html': async referer => {
|
|
226
|
-
await post('/_/QUnit/begin', referer, { totalTests: 0, modules: [] })
|
|
227
|
-
await post('/_/QUnit/done', referer, { failed: 0 })
|
|
228
|
-
await post('/_/QUnit/testStart', referer, { module: 'module', name: 'test', testId: '1' })
|
|
229
|
-
await post('/_/QUnit/testDone', referer, { testId: '1', failed: 0, passed: 1 })
|
|
230
|
-
await post('/_/QUnit/done', referer, { failed: 0 })
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
await safeExecute()
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
it('succeeded', () => {
|
|
237
|
-
expect(job.failed).toStrictEqual(false)
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
describe('error', () => {
|
|
242
|
-
describe('one test fail', () => {
|
|
243
|
-
beforeAll(async () => {
|
|
244
|
-
await setup('error1')
|
|
245
|
-
pages = {
|
|
246
|
-
'testsuite.qunit.html': async referer => {
|
|
247
|
-
await post('/_/addTestPages', referer, [
|
|
248
|
-
'/page1.html',
|
|
249
|
-
'/page2.html'
|
|
250
|
-
])
|
|
251
|
-
},
|
|
252
|
-
'page1.html': referer => simulateOK(referer),
|
|
253
|
-
'page2.html': async referer => {
|
|
254
|
-
await post('/_/QUnit/begin', referer, { totalTests: 1, modules: [{ tests: [{ testId: '1' }] }] })
|
|
255
|
-
await post('/_/QUnit/testDone', referer, { testId: '1', failed: 1, passed: 0 })
|
|
256
|
-
await post('/_/QUnit/done', referer, { failed: 1 })
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
await safeExecute()
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
it('failed', () => {
|
|
263
|
-
expect(job.failed).toStrictEqual(true)
|
|
264
|
-
})
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
describe('several tests fail', () => {
|
|
268
|
-
beforeAll(async () => {
|
|
269
|
-
await setup('errorN')
|
|
270
|
-
pages = {
|
|
271
|
-
'testsuite.qunit.html': async referer => {
|
|
272
|
-
await post('/_/addTestPages', referer, [
|
|
273
|
-
'/page1.html',
|
|
274
|
-
'/page2.html',
|
|
275
|
-
'/page3.html'
|
|
276
|
-
])
|
|
277
|
-
},
|
|
278
|
-
'page1.html': referer => simulateOK(referer),
|
|
279
|
-
'page2.html': async referer => {
|
|
280
|
-
await post('/_/QUnit/begin', referer, { totalTests: 1, modules: [{ tests: [{ testId: '1' }] }] })
|
|
281
|
-
await post('/_/QUnit/testDone', referer, { testId: '1', failed: 1, passed: 0 })
|
|
282
|
-
await post('/_/QUnit/done', referer, { failed: 1 })
|
|
283
|
-
},
|
|
284
|
-
'page3.html': async referer => {
|
|
285
|
-
await post('/_/QUnit/begin', referer, { totalTests: 2, modules: [{ tests: [{ testId: '2' }, { testId: '3' }] }] })
|
|
286
|
-
await post('/_/QUnit/testDone', referer, { testId: '2', failed: 2, passed: 0 })
|
|
287
|
-
await post('/_/QUnit/testDone', referer, { testId: '3', failed: 1, passed: 0 })
|
|
288
|
-
await post('/_/QUnit/done', referer, { failed: 3 })
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
await safeExecute()
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('failed', () => {
|
|
295
|
-
expect(job.failed).toStrictEqual(true)
|
|
296
|
-
})
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
describe('invalid QUnit hooks', () => {
|
|
300
|
-
beforeAll(async () => {
|
|
301
|
-
await setup('errorQunit')
|
|
302
|
-
pages = {
|
|
303
|
-
'testsuite.qunit.html': async referer => {
|
|
304
|
-
await post('/_/addTestPages', referer, [
|
|
305
|
-
'/page1.html',
|
|
306
|
-
'/page2.html'
|
|
307
|
-
])
|
|
308
|
-
},
|
|
309
|
-
'page1.html': async referer => {
|
|
310
|
-
simulateOK(referer)
|
|
311
|
-
},
|
|
312
|
-
'page2.html': async referer => {
|
|
313
|
-
// The next call will dump an error because the missing /_/QUnit/begin call generates the page structure
|
|
314
|
-
await post('/_/QUnit/testDone', referer, { failed: 1, passed: 0 })
|
|
315
|
-
await post('/_/QUnit/done', referer, { failed: 1 })
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
await safeExecute()
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
it('failed', () => {
|
|
322
|
-
expect(job.failed).toStrictEqual(true)
|
|
323
|
-
})
|
|
324
|
-
})
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
describe('global timeout', () => {
|
|
328
|
-
beforeAll(async () => {
|
|
329
|
-
await setup('global-timeout', {
|
|
330
|
-
parallel: 1,
|
|
331
|
-
globalTimeout: 10000
|
|
332
|
-
})
|
|
333
|
-
pages = {
|
|
334
|
-
'testsuite.qunit.html': async referer => {
|
|
335
|
-
await post('/_/addTestPages', referer, [
|
|
336
|
-
'/page1.html',
|
|
337
|
-
'/page2.html'
|
|
338
|
-
])
|
|
339
|
-
},
|
|
340
|
-
'page1.html': async headers => {
|
|
341
|
-
job.globalTimeout = 1 // Update to ensure the code will globally time out *after* page1
|
|
342
|
-
simulateOK(headers)
|
|
343
|
-
},
|
|
344
|
-
'page2.html': async headers => {
|
|
345
|
-
expect(false).toStrictEqual(true) // Should not be executed
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
await safeExecute()
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
it('failed', () => {
|
|
352
|
-
expect(job.failed).toStrictEqual(true)
|
|
353
|
-
expect(job.timedOut).toStrictEqual(true)
|
|
354
|
-
})
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
describe('page timeout', () => {
|
|
358
|
-
beforeAll(async () => {
|
|
359
|
-
await setup('page-timeout', {
|
|
360
|
-
parallel: 1,
|
|
361
|
-
pageTimeout: 250
|
|
362
|
-
})
|
|
363
|
-
pages = {
|
|
364
|
-
'testsuite.qunit.html': async referer => {
|
|
365
|
-
await post('/_/addTestPages', referer, [
|
|
366
|
-
'/page1.html'
|
|
367
|
-
])
|
|
368
|
-
},
|
|
369
|
-
'page1.html': async headers => {
|
|
370
|
-
await post('/_/QUnit/begin', headers, {
|
|
371
|
-
totalTests: 3,
|
|
372
|
-
modules: [{
|
|
373
|
-
name: '0',
|
|
374
|
-
tests: [{
|
|
375
|
-
name: '1',
|
|
376
|
-
testId: '1'
|
|
377
|
-
}, {
|
|
378
|
-
name: '2',
|
|
379
|
-
testId: '2'
|
|
380
|
-
}, {
|
|
381
|
-
name: '3',
|
|
382
|
-
testId: '3'
|
|
383
|
-
}]
|
|
384
|
-
}]
|
|
385
|
-
})
|
|
386
|
-
await post('/_/QUnit/testStart', headers, { module: '0', name: '1', testId: '1' })
|
|
387
|
-
await post('/_/QUnit/testDone', headers, { testId: '1', failed: 0, passed: 1 })
|
|
388
|
-
await post('/_/QUnit/testStart', headers, { module: '0', name: '2', testId: '2' })
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
await safeExecute()
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
it('failed', () => {
|
|
395
|
-
expect(job.failed).toStrictEqual(true)
|
|
396
|
-
expect(job.timedOut).toStrictEqual(true)
|
|
397
|
-
const page = job.qunitPages['http://localhost:0/page1.html']
|
|
398
|
-
expect(page.failed).toStrictEqual(2)
|
|
399
|
-
expect(page.end).not.toBeUndefined()
|
|
400
|
-
expect(page.timedOut).toStrictEqual(true)
|
|
401
|
-
const { tests } = page.modules[0]
|
|
402
|
-
expect(tests[1].report.failed).toStrictEqual(1)
|
|
403
|
-
expect(tests[1].report.passed).toStrictEqual(0)
|
|
404
|
-
expect(tests[1].end).not.toBeUndefined()
|
|
405
|
-
expect(tests[2].report.failed).toStrictEqual(1)
|
|
406
|
-
expect(tests[2].report.passed).toStrictEqual(0)
|
|
407
|
-
expect(tests[2].start).toBeUndefined()
|
|
408
|
-
expect(tests[2].end).toBeUndefined()
|
|
409
|
-
})
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
describe('coverage substitution and ui5 cache', () => {
|
|
413
|
-
let ui5Cache
|
|
414
|
-
|
|
415
|
-
beforeAll(async () => {
|
|
416
|
-
ui5Cache = join(__dirname, '../tmp/simulate/coverage_and_cache/ui5')
|
|
417
|
-
await cleanDir(ui5Cache)
|
|
418
|
-
await setup('coverage_and_cache', {
|
|
419
|
-
cache: ui5Cache,
|
|
420
|
-
coverage: true,
|
|
421
|
-
browserRetry: 0
|
|
422
|
-
})
|
|
423
|
-
pages = {
|
|
424
|
-
'testsuite.qunit.html': async referer => {
|
|
425
|
-
const cachedResponses = await Promise.all([
|
|
426
|
-
get('/resources/sap-ui-core.js', referer),
|
|
427
|
-
get('/resources/sap-ui-core.js', referer)
|
|
428
|
-
])
|
|
429
|
-
expect(cachedResponses[0].statusCode).toStrictEqual(200)
|
|
430
|
-
expect(cachedResponses[0].toString().includes('sap-ui-core.js */')).toStrictEqual(true)
|
|
431
|
-
const notFoundResponse = await get('/resources/not-found.js', referer)
|
|
432
|
-
expect(notFoundResponse.statusCode).toStrictEqual(404)
|
|
433
|
-
const errorResponse = await get('/resources/error.js', referer)
|
|
434
|
-
expect(errorResponse.statusCode).toStrictEqual(500)
|
|
435
|
-
await post('/_/addTestPages', referer, [
|
|
436
|
-
'/page1.html',
|
|
437
|
-
'/page2.html'
|
|
438
|
-
])
|
|
439
|
-
},
|
|
440
|
-
'page1.html': async referer => {
|
|
441
|
-
const coverageResponse = await get('/component.js', referer)
|
|
442
|
-
expect(coverageResponse.statusCode).toStrictEqual(200)
|
|
443
|
-
expect(coverageResponse.toString().includes('UIComponent.extend(\'app.Component\'')).toStrictEqual(true)
|
|
444
|
-
expect(coverageResponse.toString().includes('var global=new Function("return this")();')).toStrictEqual(false)
|
|
445
|
-
expect(coverageResponse.toString().includes('var global=window.top;')).toStrictEqual(true)
|
|
446
|
-
const cachedResponse = await get('/resources/sap/ui/thirdparty/qunit.js', referer)
|
|
447
|
-
expect(cachedResponse.statusCode).toStrictEqual(200)
|
|
448
|
-
expect(cachedResponse.toString().includes('qunit.js */')).toStrictEqual(true)
|
|
449
|
-
expect(cachedResponse.toString().includes('QUnit/begin')).toStrictEqual(true)
|
|
450
|
-
simulateOK(referer, {})
|
|
451
|
-
},
|
|
452
|
-
'page2.html': async referer => {
|
|
453
|
-
const cachedResponse = await get('/resources/not-found.js', referer)
|
|
454
|
-
expect(cachedResponse.statusCode).toStrictEqual(404)
|
|
455
|
-
simulateOK(referer, {})
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
await safeExecute()
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
it('succeeded', () => {
|
|
462
|
-
expect(job.failed).toStrictEqual(false)
|
|
463
|
-
})
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
describe('error and failFast (stop after first failure)', () => {
|
|
467
|
-
beforeAll(async () => {
|
|
468
|
-
await setup('fail_fast', {
|
|
469
|
-
parallel: 1,
|
|
470
|
-
failFast: null
|
|
471
|
-
})
|
|
472
|
-
pages = {
|
|
473
|
-
'testsuite.qunit.html': async headers => {
|
|
474
|
-
await post('/_/addTestPages', headers, [
|
|
475
|
-
'/page1.html',
|
|
476
|
-
'/page2.html',
|
|
477
|
-
'/page3.html',
|
|
478
|
-
'/page4.html'
|
|
479
|
-
])
|
|
480
|
-
},
|
|
481
|
-
'page1.html': async referer => {
|
|
482
|
-
simulateOK(referer)
|
|
483
|
-
},
|
|
484
|
-
'page2.html': async referer => {
|
|
485
|
-
await post('/_/QUnit/begin', referer, { totalTests: 1 })
|
|
486
|
-
await post('/_/QUnit/testDone', referer, { failed: 1, passed: 0 })
|
|
487
|
-
await post('/_/QUnit/done', referer, { failed: 1 })
|
|
488
|
-
}
|
|
489
|
-
// Should not try to run page 3 & 4
|
|
490
|
-
}
|
|
491
|
-
await execute(job)
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
it('failed', () => {
|
|
495
|
-
expect(job.failed).toStrictEqual(true)
|
|
496
|
-
})
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
describe('error when no page found', () => {
|
|
500
|
-
beforeAll(async () => {
|
|
501
|
-
await setup('no_page', {
|
|
502
|
-
parallel: 1
|
|
503
|
-
})
|
|
504
|
-
pages = {
|
|
505
|
-
'testsuite.qunit.html': async referer => {
|
|
506
|
-
await post('/_/addTestPages', referer, [])
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
await execute(job)
|
|
510
|
-
})
|
|
511
|
-
|
|
512
|
-
it('failed', () => {
|
|
513
|
-
expect(job.failed).toStrictEqual(true)
|
|
514
|
-
})
|
|
515
|
-
})
|
|
516
|
-
|
|
517
|
-
describe('ui5 libraries', () => {
|
|
518
|
-
beforeAll(async () => {
|
|
519
|
-
await setup('libs', {
|
|
520
|
-
ui5: 'https://any.cdn.com/',
|
|
521
|
-
libs: [dirname(__dirname), `inject/=${join(__dirname, 'inject')}`]
|
|
522
|
-
})
|
|
523
|
-
pages = {
|
|
524
|
-
'testsuite.qunit.html': async referer => {
|
|
525
|
-
await post('/_/addTestPages', referer, [
|
|
526
|
-
'/page1.html'
|
|
527
|
-
])
|
|
528
|
-
},
|
|
529
|
-
'page1.html': async referer => {
|
|
530
|
-
const response1 = await get('/resources/inject/qunit-hooks.js', referer)
|
|
531
|
-
expect(response1.statusCode).toStrictEqual(200)
|
|
532
|
-
expect(response1.toString().includes('/* Injected QUnit hooks */')).toStrictEqual(true)
|
|
533
|
-
const response2 = await get('/resources/src/inject/qunit-hooks.js', referer)
|
|
534
|
-
expect(response2.statusCode).toStrictEqual(200)
|
|
535
|
-
expect(response2.toString().includes('/* Injected QUnit hooks */')).toStrictEqual(true)
|
|
536
|
-
simulateOK(referer)
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
await execute(job)
|
|
540
|
-
})
|
|
541
|
-
|
|
542
|
-
it('succeeded', () => {
|
|
543
|
-
expect(job.failed).toStrictEqual(false)
|
|
544
|
-
})
|
|
545
|
-
})
|
|
546
|
-
})
|
|
547
|
-
})
|
package/src/timeout.spec.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const { getPageTimeout, globallyTimedOut } = require('./timeout')
|
|
2
|
-
|
|
3
|
-
describe('src/timeout', () => {
|
|
4
|
-
describe('getPageTimeout', () => {
|
|
5
|
-
it('returns 0 when no timeout is defined', () => {
|
|
6
|
-
expect(getPageTimeout({})).toStrictEqual(0)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it('returns pageTimeout when no globalTimeout is defined', () => {
|
|
10
|
-
expect(getPageTimeout({ pageTimeout: 123 })).toStrictEqual(123)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('returns pageTimeout if smaller than globalTimeout', () => {
|
|
14
|
-
expect(getPageTimeout({ pageTimeout: 123, globalTimeout: 1000, start: new Date() })).toStrictEqual(123)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('returns reminder of the globalTimeout', () => {
|
|
18
|
-
expect(getPageTimeout({ globalTimeout: 10, start: new Date() })).not.toStrictEqual(0)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('returns reminder of the globalTimeout if smaller than pageTimeout', () => {
|
|
22
|
-
expect(getPageTimeout({ pageTimeout: 123, globalTimeout: 10, start: new Date() })).not.toStrictEqual(123)
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
describe('globallyTimedOut', () => {
|
|
27
|
-
it('returns false if no globalTimeout', () => {
|
|
28
|
-
expect(globallyTimedOut({})).toStrictEqual(false)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('returns false if not globally timed out', () => {
|
|
32
|
-
expect(globallyTimedOut({ globalTimeout: 1000, start: new Date() })).toStrictEqual(false)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('returns true if globally timed out', () => {
|
|
36
|
-
expect(globallyTimedOut({ globalTimeout: 10, start: new Date(Date.now() - 1000) })).toStrictEqual(true)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
package/src/tools.spec.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
const { filename, noop, pad } = require('./tools')
|
|
2
|
-
|
|
3
|
-
describe('src/tools', () => {
|
|
4
|
-
describe('filename', () => {
|
|
5
|
-
const baseUrl = 'http://localhost:8085/test.html'
|
|
6
|
-
|
|
7
|
-
it('generates unique IDs for different search param', () => {
|
|
8
|
-
const id1 = filename(baseUrl + '?param1')
|
|
9
|
-
const id2 = filename(baseUrl + '?param2')
|
|
10
|
-
expect(id1).not.toBe(id2)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('generates similar IDs for different hashes', () => {
|
|
14
|
-
const id1 = filename(baseUrl + '#param1')
|
|
15
|
-
const id2 = filename(baseUrl + '#param2')
|
|
16
|
-
expect(id1).toBe(id2)
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe('noop', () => {
|
|
21
|
-
it('is an empty function', () => {
|
|
22
|
-
expect(noop()).toBeUndefined()
|
|
23
|
-
expect(() => noop()).not.toThrow()
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
describe('pad', () => {
|
|
28
|
-
it('works if no operator is given', () => {
|
|
29
|
-
expect(pad(20)`abc`).toStrictEqual('abc')
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('fails if several operators are given', () => {
|
|
33
|
-
expect(() => pad()`${pad.x('-')}${pad.x('+')}`).toThrow()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('extends a string (begin)', () => {
|
|
37
|
-
expect(pad(20)`${pad.x('-')}12`).toStrictEqual('------------------12')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('extends a string (middle)', () => {
|
|
41
|
-
expect(pad(20)`1${pad.x('-')}2`).toStrictEqual('1------------------2')
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('extends a string (multiple interpolation)', () => {
|
|
45
|
-
expect(pad(20)`1${'3'}${pad.x('-')}${'4'}2`).toStrictEqual('13----------------42')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('extends a string (end)', () => {
|
|
49
|
-
expect(pad(20)`12${pad.x('-')}`).toStrictEqual('12------------------')
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('extends a string (multiple chars)', () => {
|
|
53
|
-
expect(pad(20)`1${pad.x('-+')}2`).toStrictEqual('1-+-+-+-+-+-+-+-+-+2')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('left trims a string', () => {
|
|
57
|
-
expect(pad(20)`1${pad.lt('abcdefghijklmnopqrstuvwxyz')}2`).toStrictEqual('1...lmnopqrstuvwxyz2')
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('left trims a small string', () => {
|
|
61
|
-
expect(pad(20)`1${pad.lt('abcdef')}2`).toStrictEqual('1abcdef 2')
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('wraps text (small enough)', () => {
|
|
65
|
-
expect(pad(20)`1${pad.w('abcdef')}2`).toStrictEqual('1abcdef 2')
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('wraps multiline', () => {
|
|
69
|
-
expect(pad(20)`1${pad.w('a\nb')}2`)
|
|
70
|
-
.toStrictEqual(`1a 2
|
|
71
|
-
1b 2`)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('wraps multiline / long text', () => {
|
|
75
|
-
expect(pad(20)`1${pad.w('first line\nsecond longer line to wrap\nfits exactly width')}2`)
|
|
76
|
-
.toStrictEqual(`1first line 2
|
|
77
|
-
1second longer lin↵2
|
|
78
|
-
1e to wrap 2
|
|
79
|
-
1fits exactly width2`)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('wraps multiline / long text (DOS carriage return)', () => {
|
|
83
|
-
expect(pad(20)`1${pad.w('first line\r\nsecond longer line to wrap\r\nfits exactly width')}2`)
|
|
84
|
-
.toStrictEqual(`1first line 2
|
|
85
|
-
1second longer lin↵2
|
|
86
|
-
1e to wrap 2
|
|
87
|
-
1fits exactly width2`)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
})
|