ui5-test-runner 4.0.0 → 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 +0 -15
- package/package.json +3 -8
- package/src/coverage.js +51 -42
- 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 +3 -6
- package/src/output.js +50 -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 -424
- 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/qunit-hooks.js
CHANGED
|
@@ -17,12 +17,38 @@ function invalidTestId (job, url, testId) {
|
|
|
17
17
|
error(job, url, `No QUnit unit test found with id ${testId}`)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function merge (targetModules, modules) {
|
|
21
|
+
let count = 0
|
|
22
|
+
modules.forEach(module => {
|
|
23
|
+
const { name } = module
|
|
24
|
+
const targetModule = targetModules.filter(({ name: targetName }) => name === targetName)[0]
|
|
25
|
+
if (targetModule === undefined) {
|
|
26
|
+
targetModules.push(module)
|
|
27
|
+
} else {
|
|
28
|
+
module.tests.forEach(test => {
|
|
29
|
+
const targetTest = targetModule.tests.filter(({ testId }) => test.testId === testId)[0]
|
|
30
|
+
if (!targetTest) {
|
|
31
|
+
targetModule.tests.push(test)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
count += module.tests.length
|
|
36
|
+
})
|
|
37
|
+
return count
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function get (job, urlWithHash, { testId, modules, isOpa } = {}) {
|
|
21
41
|
const url = stripUrlHash(urlWithHash)
|
|
22
42
|
const page = job.qunitPages && job.qunitPages[url]
|
|
23
43
|
if (!page) {
|
|
24
44
|
error(job, url, `No QUnit page found for ${urlWithHash}`)
|
|
25
45
|
}
|
|
46
|
+
if (modules && modules.length) {
|
|
47
|
+
page.count = merge(page.modules, modules)
|
|
48
|
+
}
|
|
49
|
+
if (!page.isOpa && isOpa) {
|
|
50
|
+
page.isOpa = true
|
|
51
|
+
}
|
|
26
52
|
let testModule
|
|
27
53
|
let test
|
|
28
54
|
if (testId !== undefined) {
|
|
@@ -35,7 +61,7 @@ function get (job, urlWithHash, testId) {
|
|
|
35
61
|
return false
|
|
36
62
|
}
|
|
37
63
|
})
|
|
38
|
-
if (!test
|
|
64
|
+
if (!test) {
|
|
39
65
|
invalidTestId(job, url, testId)
|
|
40
66
|
}
|
|
41
67
|
}
|
|
@@ -44,7 +70,7 @@ function get (job, urlWithHash, testId) {
|
|
|
44
70
|
|
|
45
71
|
async function done (job, urlWithHash, report) {
|
|
46
72
|
const { url, page } = get(job, urlWithHash)
|
|
47
|
-
if (page.
|
|
73
|
+
if (page.count === 0) {
|
|
48
74
|
return // wait
|
|
49
75
|
}
|
|
50
76
|
if (job.browserCapabilities.screenshot) {
|
|
@@ -66,15 +92,10 @@ async function done (job, urlWithHash, report) {
|
|
|
66
92
|
module.exports = {
|
|
67
93
|
get,
|
|
68
94
|
|
|
69
|
-
async begin (job, urlWithHash,
|
|
95
|
+
async begin (job, urlWithHash, details) {
|
|
96
|
+
getOutput(job).debug('qunit', 'begin', urlWithHash, details)
|
|
97
|
+
const { isOpa, totalTests, modules } = details
|
|
70
98
|
const url = stripUrlHash(urlWithHash)
|
|
71
|
-
const earlyStart = !totalTests || !modules
|
|
72
|
-
if (earlyStart) {
|
|
73
|
-
getOutput(job).qunitEarlyStart(url)
|
|
74
|
-
if (job.qunitStrict) {
|
|
75
|
-
error(job, url, 'Invalid begin hook details')
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
99
|
if (!job.qunitPages) {
|
|
79
100
|
job.qunitPages = {}
|
|
80
101
|
}
|
|
@@ -87,28 +108,19 @@ module.exports = {
|
|
|
87
108
|
count: totalTests,
|
|
88
109
|
modules
|
|
89
110
|
}
|
|
90
|
-
if (earlyStart) {
|
|
91
|
-
qunitPage.earlyStart = true
|
|
92
|
-
}
|
|
93
111
|
job.qunitPages[url] = qunitPage
|
|
94
112
|
},
|
|
95
113
|
|
|
96
|
-
async testStart (job, urlWithHash,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
testModule = { name: module, tests: [] }
|
|
100
|
-
page.modules.push(testModule)
|
|
101
|
-
}
|
|
102
|
-
if (!test) {
|
|
103
|
-
test = { name, testId }
|
|
104
|
-
testModule.tests.push(test)
|
|
105
|
-
++page.count
|
|
106
|
-
}
|
|
114
|
+
async testStart (job, urlWithHash, details) {
|
|
115
|
+
getOutput(job).debug('qunit', 'testStart', urlWithHash, details)
|
|
116
|
+
const { test } = get(job, urlWithHash, details)
|
|
107
117
|
test.start = new Date()
|
|
108
118
|
},
|
|
109
119
|
|
|
110
|
-
async log (job, urlWithHash,
|
|
111
|
-
|
|
120
|
+
async log (job, urlWithHash, details) {
|
|
121
|
+
getOutput(job).debug('qunit', 'log', urlWithHash, details)
|
|
122
|
+
const { url, page, test } = get(job, urlWithHash, details)
|
|
123
|
+
const { isOpa, modules, module, name, testId, ...log } = details
|
|
112
124
|
if (!test) {
|
|
113
125
|
invalidTestId(job, url, testId)
|
|
114
126
|
}
|
|
@@ -126,9 +138,11 @@ module.exports = {
|
|
|
126
138
|
}
|
|
127
139
|
},
|
|
128
140
|
|
|
129
|
-
async testDone (job, urlWithHash,
|
|
141
|
+
async testDone (job, urlWithHash, details) {
|
|
142
|
+
getOutput(job).debug('qunit', 'testDone', urlWithHash, details)
|
|
143
|
+
const { name, module, testId, assertions, ...report } = details
|
|
130
144
|
const { failed } = report
|
|
131
|
-
const { url, page, test } = get(job, urlWithHash, testId)
|
|
145
|
+
const { url, page, test } = get(job, urlWithHash, { testId })
|
|
132
146
|
if (!test) {
|
|
133
147
|
invalidTestId(job, url, testId)
|
|
134
148
|
}
|
package/src/symbols.js
CHANGED
|
@@ -5,5 +5,6 @@ module.exports = {
|
|
|
5
5
|
$testPagesStarted: Symbol('testPagesStarted'),
|
|
6
6
|
$testPagesCompleted: Symbol('testPagesCompleted'),
|
|
7
7
|
$valueSources: Symbol('valueSources'),
|
|
8
|
-
$remoteOnLegacy: Symbol('remoteOnLegacy')
|
|
8
|
+
$remoteOnLegacy: Symbol('remoteOnLegacy'),
|
|
9
|
+
$proxifiedUrls: Symbol('proxifiedUrls')
|
|
9
10
|
}
|
package/src/tests.js
CHANGED
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
$testPagesCompleted
|
|
14
14
|
} = require('./symbols')
|
|
15
15
|
const { UTRError } = require('./error')
|
|
16
|
+
const { $proxifiedUrls } = require('./symbols')
|
|
16
17
|
|
|
17
18
|
async function run (task, job) {
|
|
18
19
|
const {
|
|
@@ -70,7 +71,7 @@ async function runTestPage (job, url) {
|
|
|
70
71
|
const output = getOutput(job)
|
|
71
72
|
try {
|
|
72
73
|
let scripts
|
|
73
|
-
if (job.
|
|
74
|
+
if (job.browserCapabilities.scripts) {
|
|
74
75
|
scripts = [
|
|
75
76
|
'post.js',
|
|
76
77
|
'qunit-intercept.js',
|
|
@@ -86,6 +87,10 @@ async function runTestPage (job, url) {
|
|
|
86
87
|
if (job.coverageProxy) {
|
|
87
88
|
const { origin } = new URL(url)
|
|
88
89
|
const proxifiedUrl = url.replace(origin, `http://localhost:${job.port}`)
|
|
90
|
+
if (!job[$proxifiedUrls]) {
|
|
91
|
+
job[$proxifiedUrls] = {}
|
|
92
|
+
}
|
|
93
|
+
job[$proxifiedUrls][proxifiedUrl] = url
|
|
89
94
|
await start(job, proxifiedUrl, scripts)
|
|
90
95
|
job.qunitPages[url] = job.qunitPages[proxifiedUrl]
|
|
91
96
|
delete job.qunitPages[proxifiedUrl]
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
jest.mock('./browsers.js', () => ({
|
|
2
|
-
stop: jest.fn()
|
|
3
|
-
}))
|
|
4
|
-
const { stop } = require('./browsers')
|
|
5
|
-
const { join } = require('path')
|
|
6
|
-
const { createDir } = require('./tools')
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
addTestPages
|
|
10
|
-
} = require('./add-test-pages')
|
|
11
|
-
|
|
12
|
-
describe('src/add-test-pages', () => {
|
|
13
|
-
const url = 'http://localhost:8045/index.html'
|
|
14
|
-
const reportDir = join(__dirname, '../tmp/add-test-pages')
|
|
15
|
-
let job
|
|
16
|
-
|
|
17
|
-
beforeAll(() => createDir(reportDir))
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
stop.mockClear()
|
|
21
|
-
job = {
|
|
22
|
-
reportDir
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
describe('addTestPages', () => {
|
|
27
|
-
it('keeps track of added test pages and stops browser', async () => {
|
|
28
|
-
await addTestPages(job, url, [
|
|
29
|
-
'/page1.html',
|
|
30
|
-
'page2.html'
|
|
31
|
-
])
|
|
32
|
-
expect(job.testPageUrls).toEqual([
|
|
33
|
-
'http://localhost:8045/page1.html',
|
|
34
|
-
'http://localhost:8045/page2.html'
|
|
35
|
-
])
|
|
36
|
-
expect(stop).toHaveBeenCalledWith(job, url)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('supports regexp filtering', async () => {
|
|
40
|
-
job.pageFilter = 'page(1|3)'
|
|
41
|
-
await addTestPages(job, url, [
|
|
42
|
-
'/page1.html',
|
|
43
|
-
'page2.html',
|
|
44
|
-
'page3.html'
|
|
45
|
-
])
|
|
46
|
-
expect(job.testPageUrls).toEqual([
|
|
47
|
-
'http://localhost:8045/page1.html',
|
|
48
|
-
'http://localhost:8045/page3.html'
|
|
49
|
-
])
|
|
50
|
-
expect(stop).toHaveBeenCalledWith(job, url)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('supports parameters injection', async () => {
|
|
54
|
-
job.pageParams = 'a&b'
|
|
55
|
-
await addTestPages(job, url, [
|
|
56
|
-
'/page1.html',
|
|
57
|
-
'page2.html?test'
|
|
58
|
-
])
|
|
59
|
-
expect(job.testPageUrls).toEqual([
|
|
60
|
-
'http://localhost:8045/page1.html?a&b',
|
|
61
|
-
'http://localhost:8045/page2.html?test&a&b'
|
|
62
|
-
])
|
|
63
|
-
expect(stop).toHaveBeenCalledWith(job, url)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('filters out duplicates', async () => {
|
|
67
|
-
await addTestPages(job, url, [
|
|
68
|
-
'/page1.html',
|
|
69
|
-
'page1.html'
|
|
70
|
-
])
|
|
71
|
-
expect(job.testPageUrls).toEqual([
|
|
72
|
-
'http://localhost:8045/page1.html'
|
|
73
|
-
])
|
|
74
|
-
expect(stop).toHaveBeenCalledWith(job, url)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it('supports multiple calls', async () => {
|
|
78
|
-
await addTestPages(job, url, ['/page1.html'])
|
|
79
|
-
await addTestPages(job, url, ['page1.html', '/page2.html'])
|
|
80
|
-
expect(job.testPageUrls).toEqual([
|
|
81
|
-
'http://localhost:8045/page1.html',
|
|
82
|
-
'http://localhost:8045/page2.html'
|
|
83
|
-
])
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('supports absolute urls', async () => {
|
|
87
|
-
await addTestPages(job, url, ['/page1.html'])
|
|
88
|
-
await addTestPages(job, url, ['http://localhost:8045/page2.html'])
|
|
89
|
-
expect(job.testPageUrls).toEqual([
|
|
90
|
-
'http://localhost:8045/page1.html',
|
|
91
|
-
'http://localhost:8045/page2.html'
|
|
92
|
-
])
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
})
|