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/cors.spec.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use script'
|
|
2
|
-
|
|
3
|
-
const Request = require('reserve/mock/Request')
|
|
4
|
-
const Response = require('reserve/mock/Response')
|
|
5
|
-
const cors = require('./cors')
|
|
6
|
-
|
|
7
|
-
const origin = 'npmjs.com'
|
|
8
|
-
|
|
9
|
-
describe('src/cors', () => {
|
|
10
|
-
it('handles CORS attributes', async () => {
|
|
11
|
-
const request = new Request('GET', '/', { origin })
|
|
12
|
-
const response = new Response()
|
|
13
|
-
cors.custom(request, response)
|
|
14
|
-
expect(response.statusCode).toBeUndefined()
|
|
15
|
-
expect(response.headers).toMatchObject({
|
|
16
|
-
'access-control-allow-origin': origin,
|
|
17
|
-
'access-control-allow-credentials': 'true'
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('does not impact response if origin is missing', async () => {
|
|
22
|
-
const request = new Request('GET', '/')
|
|
23
|
-
const response = new Response()
|
|
24
|
-
cors.custom(request, response)
|
|
25
|
-
expect(response.statusCode).toBeUndefined()
|
|
26
|
-
expect(response.headers).toMatchObject({})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('handles CORS preflight', async () => {
|
|
30
|
-
const request = new Request('OPTIONS', '/', { origin })
|
|
31
|
-
const response = new Response()
|
|
32
|
-
cors.custom(request, response)
|
|
33
|
-
expect(response.statusCode).toStrictEqual(200)
|
|
34
|
-
expect(response.headers).toMatchObject({
|
|
35
|
-
'access-control-allow-origin': origin,
|
|
36
|
-
'access-control-allow-headers': 'content-type, content-length, x-page-url',
|
|
37
|
-
'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
|
38
|
-
'access-control-allow-credentials': 'true'
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
})
|
package/src/coverage.spec.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const { join } = require('path')
|
|
2
|
-
const { fromObject } = require('./job')
|
|
3
|
-
const { instrument, generateCoverageReport, mappings } = require('./coverage')
|
|
4
|
-
const { stat } = require('fs/promises')
|
|
5
|
-
const { cleanDir, createDir } = require('./tools')
|
|
6
|
-
const { getOutput } = require('./output')
|
|
7
|
-
const { $remoteOnLegacy } = require('./symbols')
|
|
8
|
-
|
|
9
|
-
describe('src/coverage', () => {
|
|
10
|
-
const cwd = join(__dirname, '../test/project')
|
|
11
|
-
const path = join(__dirname, '../tmp/coverage')
|
|
12
|
-
|
|
13
|
-
beforeAll(() => {
|
|
14
|
-
return cleanDir(path)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
describe('disabled', () => {
|
|
18
|
-
const basePath = join(path, 'disabled')
|
|
19
|
-
let job
|
|
20
|
-
|
|
21
|
-
beforeAll(async () => {
|
|
22
|
-
const reportDir = join(basePath, 'report')
|
|
23
|
-
await createDir(reportDir)
|
|
24
|
-
job = fromObject(cwd, {
|
|
25
|
-
reportDir,
|
|
26
|
-
coverageTempDir: join(basePath, 'coverage/temp'),
|
|
27
|
-
coverageReportDir: join(basePath, 'coverage/report'),
|
|
28
|
-
coverage: false
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('does not instrument sources', async () => {
|
|
33
|
-
await instrument(job)
|
|
34
|
-
await expect(() => stat(join(basePath, 'coverage/temp/settings/nyc.json'))).rejects.toThrow()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('does not generate a report', async () => {
|
|
38
|
-
await generateCoverageReport(job)
|
|
39
|
-
await expect(() => stat(join(basePath, 'coverage/temp/coverage.json'))).rejects.toThrow()
|
|
40
|
-
await expect(() => stat(join(basePath, 'coverage/report'))).rejects.toThrow()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('does not create a mapping', async () => {
|
|
44
|
-
const coverageMappings = await mappings(job)
|
|
45
|
-
expect(coverageMappings.length).toStrictEqual(0)
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('enabled', () => {
|
|
50
|
-
const basePath = join(path, 'enabled')
|
|
51
|
-
let job
|
|
52
|
-
|
|
53
|
-
beforeAll(async function () {
|
|
54
|
-
const reportDir = join(basePath, 'report')
|
|
55
|
-
await createDir(reportDir)
|
|
56
|
-
job = fromObject(cwd, {
|
|
57
|
-
reportDir,
|
|
58
|
-
coverageTempDir: join(basePath, 'coverage/temp'),
|
|
59
|
-
coverageReportDir: join(basePath, 'coverage/report'),
|
|
60
|
-
coverage: true
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('instruments sources', async () => {
|
|
65
|
-
await instrument(job)
|
|
66
|
-
const nycJsonStat = await stat(join(basePath, 'coverage/temp/settings/nyc.json'))
|
|
67
|
-
expect(nycJsonStat.isFile()).toStrictEqual(true)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('generates a report', async () => {
|
|
71
|
-
await generateCoverageReport(job)
|
|
72
|
-
const reportStat = await stat(join(basePath, 'coverage/report'))
|
|
73
|
-
expect(reportStat.isDirectory()).toStrictEqual(true)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('creates a mapping', async () => {
|
|
77
|
-
const coverageMappings = await mappings(job)
|
|
78
|
-
expect(coverageMappings.length).toStrictEqual(1)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
describe('--url compatibility', () => {
|
|
82
|
-
let output
|
|
83
|
-
let instrumentationSkipped
|
|
84
|
-
|
|
85
|
-
beforeAll(() => {
|
|
86
|
-
output = getOutput(job)
|
|
87
|
-
instrumentationSkipped = jest.spyOn(output, 'instrumentationSkipped')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
beforeEach(() => {
|
|
91
|
-
instrumentationSkipped.mockReset()
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
afterAll(() => {
|
|
95
|
-
instrumentationSkipped.mockRestore()
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('does *not* instrument if the URL does not match current port', async () => {
|
|
99
|
-
Object.assign(job, {
|
|
100
|
-
mode: 'url',
|
|
101
|
-
port: 8080,
|
|
102
|
-
url: ['http://localhost:8081/whatever/test.html']
|
|
103
|
-
})
|
|
104
|
-
await instrument(job)
|
|
105
|
-
expect(instrumentationSkipped).toHaveBeenCalled()
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('**does** instrument anyway if the URL matches current port', async () => {
|
|
109
|
-
Object.assign(job, {
|
|
110
|
-
mode: 'url',
|
|
111
|
-
port: 8080,
|
|
112
|
-
url: ['http://localhost:8080/whatever/test.html'],
|
|
113
|
-
[$remoteOnLegacy]: true // added on job finalization
|
|
114
|
-
})
|
|
115
|
-
await instrument(job)
|
|
116
|
-
expect(instrumentationSkipped).not.toHaveBeenCalled()
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
})
|
package/src/csv-reader.spec.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const { buildCsvReader } = require('./csv-reader')
|
|
2
|
-
const { createReadStream } = require('fs')
|
|
3
|
-
const { Readable } = require('stream')
|
|
4
|
-
|
|
5
|
-
jest.mock('fs')
|
|
6
|
-
|
|
7
|
-
describe('src/csv-reader', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
createReadStream.mockReset()
|
|
10
|
-
createReadStream.mockImplementation(() => {
|
|
11
|
-
const s = new Readable()
|
|
12
|
-
s._read = () => {}
|
|
13
|
-
s.push(`timestamp\ttext
|
|
14
|
-
1\tabc
|
|
15
|
-
2\thello world
|
|
16
|
-
3\t"abc\\td"
|
|
17
|
-
`)
|
|
18
|
-
s.push(null)
|
|
19
|
-
return s
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('allocates an iterator', () => {
|
|
24
|
-
const reader = buildCsvReader('test.csv')
|
|
25
|
-
expect(reader).not.toBeUndefined()
|
|
26
|
-
expect(typeof reader.next).toBe('function')
|
|
27
|
-
expect(createReadStream).not.toHaveBeenCalled()
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('reads records', async () => {
|
|
31
|
-
const reader = buildCsvReader('test.csv')
|
|
32
|
-
const records = []
|
|
33
|
-
for await (const record of reader) {
|
|
34
|
-
records.push(record)
|
|
35
|
-
}
|
|
36
|
-
expect(records).toEqual([
|
|
37
|
-
{ timestamp: '1', text: 'abc' },
|
|
38
|
-
{ timestamp: '2', text: 'hello world' },
|
|
39
|
-
{ timestamp: '3', text: 'abc\td' }
|
|
40
|
-
])
|
|
41
|
-
})
|
|
42
|
-
})
|
package/src/csv-writer.spec.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const { buildCsvWriter } = require('./csv-writer')
|
|
2
|
-
const { writeFile } = require('fs/promises')
|
|
3
|
-
|
|
4
|
-
jest.mock('fs/promises')
|
|
5
|
-
|
|
6
|
-
describe('src/csv-writer', () => {
|
|
7
|
-
const now = Date.now()
|
|
8
|
-
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
jest.spyOn(Date, 'now').mockImplementation(() => now)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
writeFile.mockReset()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('allocates an object', () => {
|
|
18
|
-
const writer = buildCsvWriter('test.csv')
|
|
19
|
-
expect(writer).not.toBeUndefined()
|
|
20
|
-
expect(writeFile).not.toHaveBeenCalled()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('starts writing the file on first record', async () => {
|
|
24
|
-
const writer = buildCsvWriter('test.csv')
|
|
25
|
-
writer.append({ text: 'test' })
|
|
26
|
-
await writer.ready
|
|
27
|
-
expect(writeFile.mock.calls).toEqual([
|
|
28
|
-
['test.csv', 'timestamp\ttext\n', { flag: 'a+' }],
|
|
29
|
-
['test.csv', `${now}\ttest\n`, { flag: 'a+' }]
|
|
30
|
-
])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('ignores any additional field not used on the first append', async () => {
|
|
34
|
-
const writer = buildCsvWriter('test.csv')
|
|
35
|
-
writer.append({ text: 'test 1' })
|
|
36
|
-
writer.append({ text: 'test 2', ignored: true })
|
|
37
|
-
await writer.ready
|
|
38
|
-
expect(writeFile.mock.calls).toEqual([
|
|
39
|
-
['test.csv', 'timestamp\ttext\n', { flag: 'a+' }],
|
|
40
|
-
['test.csv', `${now}\ttest 1\n`, { flag: 'a+' }],
|
|
41
|
-
['test.csv', `${now}\ttest 2\n`, { flag: 'a+' }]
|
|
42
|
-
])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('escapes automatically complex values', async () => {
|
|
46
|
-
const writer = buildCsvWriter('test.csv')
|
|
47
|
-
writer.append({ number: 1, text: 'test\t1\n' })
|
|
48
|
-
await writer.ready
|
|
49
|
-
expect(writeFile.mock.calls).toEqual([
|
|
50
|
-
['test.csv', 'timestamp\tnumber\ttext\n', { flag: 'a+' }],
|
|
51
|
-
['test.csv', `${now}\t1\t"test\\t1\\n"\n`, { flag: 'a+' }]
|
|
52
|
-
])
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('handles provided timestamp', async () => {
|
|
56
|
-
const writer = buildCsvWriter('test.csv')
|
|
57
|
-
writer.append({ timestamp: 456, number: 1, text: 'test\t1\n' })
|
|
58
|
-
await writer.ready
|
|
59
|
-
expect(writeFile.mock.calls).toEqual([
|
|
60
|
-
['test.csv', 'timestamp\tnumber\ttext\n', { flag: 'a+' }],
|
|
61
|
-
['test.csv', '456\t1\t"test\\t1\\n"\n', { flag: 'a+' }]
|
|
62
|
-
])
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('handles record array', async () => {
|
|
66
|
-
const writer = buildCsvWriter('test.csv')
|
|
67
|
-
await writer.append([
|
|
68
|
-
{ number: 1, text: 'test\t1\n' },
|
|
69
|
-
{ number: 2, text: 'test\t2\n' }
|
|
70
|
-
])
|
|
71
|
-
await writer.ready
|
|
72
|
-
expect(writeFile.mock.calls).toEqual([
|
|
73
|
-
['test.csv', 'timestamp\tnumber\ttext\n', { flag: 'a+' }],
|
|
74
|
-
['test.csv', `${now}\t1\t"test\\t1\\n"\n${now}\t2\t"test\\t2\\n"\n`, { flag: 'a+' }]
|
|
75
|
-
])
|
|
76
|
-
})
|
|
77
|
-
})
|
package/src/error.spec.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const { UTRError } = require('./error')
|
|
2
|
-
|
|
3
|
-
describe('src/errors', () => {
|
|
4
|
-
it('generates a fully documented error', () => {
|
|
5
|
-
const error = UTRError.NPM_FAILED('test')
|
|
6
|
-
expect(error.name).toStrictEqual('UTRError:NPM_FAILED')
|
|
7
|
-
expect(error.code).toBeLessThan(0)
|
|
8
|
-
expect(error.message).toStrictEqual('test')
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('generates a generic error', () => {
|
|
12
|
-
const error = UTRError.NPM_FAILED()
|
|
13
|
-
expect(error.name).toStrictEqual('UTRError:NPM_FAILED')
|
|
14
|
-
expect(error.code).toBeLessThan(0)
|
|
15
|
-
expect(error.message).toStrictEqual('NPM_FAILED')
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
const { getJobProgress } = require('./get-job-progress')
|
|
2
|
-
const { Response } = require('reserve')
|
|
3
|
-
|
|
4
|
-
describe('src/get-job-progress', () => {
|
|
5
|
-
const url = 'https://localhost:8080/tests/unitTests.qunit.html'
|
|
6
|
-
const id = 'abcdef'
|
|
7
|
-
const firstTestId = '8ef4ee8b'
|
|
8
|
-
|
|
9
|
-
const job = {
|
|
10
|
-
cwd: '.',
|
|
11
|
-
port: 8080,
|
|
12
|
-
ui5: 'https://ui5.sap.com',
|
|
13
|
-
testPageUrls: [url],
|
|
14
|
-
qunitPages: {
|
|
15
|
-
[url]: {
|
|
16
|
-
id,
|
|
17
|
-
start: '2023-01-09T12:49:34.255Z',
|
|
18
|
-
failed: 0,
|
|
19
|
-
passed: 2,
|
|
20
|
-
count: 3,
|
|
21
|
-
modules: [{
|
|
22
|
-
name: 'module',
|
|
23
|
-
tests: [{
|
|
24
|
-
name: 'First test',
|
|
25
|
-
testId: firstTestId,
|
|
26
|
-
logs: ['whatever it contains'],
|
|
27
|
-
report: {
|
|
28
|
-
skipped: false,
|
|
29
|
-
todo: false,
|
|
30
|
-
failed: 0,
|
|
31
|
-
passed: 1,
|
|
32
|
-
total: 1,
|
|
33
|
-
runtime: 3
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
name: 'Second test',
|
|
37
|
-
testId: '35d36b9d',
|
|
38
|
-
logs: [],
|
|
39
|
-
report: {
|
|
40
|
-
skipped: false,
|
|
41
|
-
todo: false,
|
|
42
|
-
failed: 0,
|
|
43
|
-
passed: 1,
|
|
44
|
-
total: 1,
|
|
45
|
-
runtime: 5
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
name: 'Third test',
|
|
49
|
-
testId: 'e32c4c98',
|
|
50
|
-
logs: [],
|
|
51
|
-
report: {
|
|
52
|
-
skipped: false,
|
|
53
|
-
todo: false,
|
|
54
|
-
failed: 1,
|
|
55
|
-
passed: 0,
|
|
56
|
-
total: 1,
|
|
57
|
-
runtime: 3
|
|
58
|
-
}
|
|
59
|
-
}]
|
|
60
|
-
}]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
it('returns job without modules', async () => {
|
|
66
|
-
const response = new Response()
|
|
67
|
-
await getJobProgress(job, {}, response)
|
|
68
|
-
await response.waitForFinish()
|
|
69
|
-
const json = JSON.parse(response.toString())
|
|
70
|
-
expect(json).toStrictEqual({
|
|
71
|
-
cwd: '.',
|
|
72
|
-
port: 8080,
|
|
73
|
-
ui5: 'https://ui5.sap.com',
|
|
74
|
-
testPageUrls: [url],
|
|
75
|
-
qunitPages: {
|
|
76
|
-
[url]: {
|
|
77
|
-
id,
|
|
78
|
-
start: '2023-01-09T12:49:34.255Z',
|
|
79
|
-
failed: 0,
|
|
80
|
-
passed: 2,
|
|
81
|
-
count: 3
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('returns page without logs from page id', async () => {
|
|
88
|
-
const response = new Response()
|
|
89
|
-
await getJobProgress(job, {}, response, id)
|
|
90
|
-
await response.waitForFinish()
|
|
91
|
-
const json = JSON.parse(response.toString())
|
|
92
|
-
expect(json).toStrictEqual({
|
|
93
|
-
url,
|
|
94
|
-
id,
|
|
95
|
-
start: '2023-01-09T12:49:34.255Z',
|
|
96
|
-
failed: 0,
|
|
97
|
-
passed: 2,
|
|
98
|
-
count: 3,
|
|
99
|
-
modules: [{
|
|
100
|
-
name: 'module',
|
|
101
|
-
tests: [{
|
|
102
|
-
name: 'First test',
|
|
103
|
-
testId: '8ef4ee8b',
|
|
104
|
-
report: {
|
|
105
|
-
skipped: false,
|
|
106
|
-
todo: false,
|
|
107
|
-
failed: 0,
|
|
108
|
-
passed: 1,
|
|
109
|
-
total: 1,
|
|
110
|
-
runtime: 3
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
name: 'Second test',
|
|
114
|
-
testId: '35d36b9d',
|
|
115
|
-
report: {
|
|
116
|
-
skipped: false,
|
|
117
|
-
todo: false,
|
|
118
|
-
failed: 0,
|
|
119
|
-
passed: 1,
|
|
120
|
-
total: 1,
|
|
121
|
-
runtime: 5
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
name: 'Third test',
|
|
125
|
-
testId: 'e32c4c98',
|
|
126
|
-
report: {
|
|
127
|
-
skipped: false,
|
|
128
|
-
todo: false,
|
|
129
|
-
failed: 1,
|
|
130
|
-
passed: 0,
|
|
131
|
-
total: 1,
|
|
132
|
-
runtime: 3
|
|
133
|
-
}
|
|
134
|
-
}]
|
|
135
|
-
}]
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
it('returns 404 if page id is unknown', async () => {
|
|
140
|
-
const response = new Response()
|
|
141
|
-
await getJobProgress(job, {}, response, 'unknown')
|
|
142
|
-
await response.waitForFinish()
|
|
143
|
-
expect(response.statusCode).toBe(404)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
it('returns test page and test id', async () => {
|
|
147
|
-
const response = new Response()
|
|
148
|
-
await getJobProgress(job, {}, response, id, firstTestId)
|
|
149
|
-
await response.waitForFinish()
|
|
150
|
-
const json = JSON.parse(response.toString())
|
|
151
|
-
expect(json).toStrictEqual({
|
|
152
|
-
url,
|
|
153
|
-
pageId: id,
|
|
154
|
-
module: 'module',
|
|
155
|
-
name: 'First test',
|
|
156
|
-
testId: firstTestId,
|
|
157
|
-
logs: ['whatever it contains'],
|
|
158
|
-
report: {
|
|
159
|
-
skipped: false,
|
|
160
|
-
todo: false,
|
|
161
|
-
failed: 0,
|
|
162
|
-
passed: 1,
|
|
163
|
-
total: 1,
|
|
164
|
-
runtime: 3
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('returns 404 if test id is unknown', async () => {
|
|
170
|
-
const response = new Response()
|
|
171
|
-
await getJobProgress(job, {}, response, id, 'unknown')
|
|
172
|
-
await response.waitForFinish()
|
|
173
|
-
expect(response.statusCode).toBe(404)
|
|
174
|
-
})
|
|
175
|
-
})
|
package/src/inject/post.spec.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
class UI5Object {}
|
|
2
|
-
global.window = {
|
|
3
|
-
sap: {
|
|
4
|
-
ui: {
|
|
5
|
-
base: {
|
|
6
|
-
Object: UI5Object
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
require('./post')
|
|
13
|
-
|
|
14
|
-
describe('src/inject/post', () => {
|
|
15
|
-
describe('stringify', () => {
|
|
16
|
-
const stringify = window['ui5-test-runner/stringify']
|
|
17
|
-
|
|
18
|
-
describe('simple values', () => {
|
|
19
|
-
const simpleValues = [
|
|
20
|
-
null,
|
|
21
|
-
'',
|
|
22
|
-
'Hello World !',
|
|
23
|
-
0,
|
|
24
|
-
1,
|
|
25
|
-
false,
|
|
26
|
-
true,
|
|
27
|
-
[],
|
|
28
|
-
[1, 2],
|
|
29
|
-
{ a: 'a' },
|
|
30
|
-
{ a: 'a', b: { b: 'b' } },
|
|
31
|
-
[{ a: 'a' }, { a: 'a', b: { b: 'b' } }]
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
simpleValues.forEach(simpleValue => {
|
|
35
|
-
it(JSON.stringify(simpleValue), () => {
|
|
36
|
-
expect(stringify(simpleValue)).toBe(JSON.stringify(simpleValue))
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('UI5 objects', () => {
|
|
42
|
-
it('reduces UI5 objects to their simplest form (no ID)', () => {
|
|
43
|
-
const obj = new UI5Object()
|
|
44
|
-
obj.getMetadata = () => ({
|
|
45
|
-
getName: () => 'sap.m.Button'
|
|
46
|
-
})
|
|
47
|
-
expect(JSON.parse(stringify(obj))).toStrictEqual({
|
|
48
|
-
'ui5:class': 'sap.m.Button'
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('reduces UI5 objects to their simplest form (with ID)', () => {
|
|
53
|
-
const obj = new UI5Object()
|
|
54
|
-
obj.getId = () => 'test'
|
|
55
|
-
obj.getMetadata = () => ({
|
|
56
|
-
getName: () => 'sap.m.Button'
|
|
57
|
-
})
|
|
58
|
-
expect(JSON.parse(stringify(obj))).toStrictEqual({
|
|
59
|
-
'ui5:id': 'test',
|
|
60
|
-
'ui5:class': 'sap.m.Button'
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('works on a complex object', () => {
|
|
65
|
-
const obj = new UI5Object()
|
|
66
|
-
obj.getId = () => 'test'
|
|
67
|
-
obj.getMetadata = () => ({
|
|
68
|
-
getName: () => 'sap.m.Button'
|
|
69
|
-
})
|
|
70
|
-
expect(JSON.parse(stringify({
|
|
71
|
-
complex: obj
|
|
72
|
-
}))).toStrictEqual({
|
|
73
|
-
complex: {
|
|
74
|
-
'ui5:id': 'test',
|
|
75
|
-
'ui5:class': 'sap.m.Button'
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
describe('circular references', () => {
|
|
82
|
-
it('converts simple circular reference (object)', () => {
|
|
83
|
-
const a = { a: 'a' }
|
|
84
|
-
const b = { b: 'b' }
|
|
85
|
-
a.b = b
|
|
86
|
-
b.a = a
|
|
87
|
-
expect(JSON.parse(stringify(a))).toStrictEqual({
|
|
88
|
-
'circular:id': 0,
|
|
89
|
-
a: 'a',
|
|
90
|
-
b: {
|
|
91
|
-
b: 'b',
|
|
92
|
-
a: {
|
|
93
|
-
'circular:ref': 0
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('converts deep circular reference', () => {
|
|
100
|
-
const a = {
|
|
101
|
-
a: 'a',
|
|
102
|
-
b: {
|
|
103
|
-
b: 'b',
|
|
104
|
-
c: ['c'],
|
|
105
|
-
d: {
|
|
106
|
-
d: 'd'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
a.b.c.push(a.b)
|
|
111
|
-
a.b.d.a = a
|
|
112
|
-
expect(JSON.parse(stringify(a))).toStrictEqual({
|
|
113
|
-
'circular:id': 0,
|
|
114
|
-
a: 'a',
|
|
115
|
-
b: {
|
|
116
|
-
'circular:id': 1,
|
|
117
|
-
b: 'b',
|
|
118
|
-
c: ['c', { 'circular:ref': 1 }],
|
|
119
|
-
d: {
|
|
120
|
-
d: 'd',
|
|
121
|
-
a: {
|
|
122
|
-
'circular:ref': 0
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it('converts simple circular reference (array)', () => {
|
|
130
|
-
const a = ['a']
|
|
131
|
-
const b = ['b']
|
|
132
|
-
a.push(b)
|
|
133
|
-
b.push(a)
|
|
134
|
-
expect(JSON.parse(stringify(a))).toStrictEqual({
|
|
135
|
-
'circular:id': 0,
|
|
136
|
-
'circular:array': [
|
|
137
|
-
'a',
|
|
138
|
-
[
|
|
139
|
-
'b',
|
|
140
|
-
{ 'circular:ref': 0 }
|
|
141
|
-
]
|
|
142
|
-
]
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
})
|