ui5-test-runner 3.1.1 → 3.2.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/package.json +3 -2
- package/src/defaults/playwright.js +124 -0
- package/src/defaults/puppeteer.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui5-test-runner",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Standalone test runner for UI5",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"lint": "standard --fix",
|
|
19
|
-
"test": "npm run test:unit && npm run test:integration:jsdom && npm run test:integration:puppeteer && npm run test:integration:selenium-webdriver-chrome",
|
|
19
|
+
"test": "npm run test:unit && npm run test:integration:jsdom && npm run test:integration:puppeteer && npm run test:integration:selenium-webdriver-chrome && npm run test:integration:playwright",
|
|
20
20
|
"test:unit": "jest",
|
|
21
21
|
"test:unit:debug": "jest --runInBand",
|
|
22
22
|
"test:integration:puppeteer": "node . --capabilities --browser $/puppeteer.js",
|
|
23
23
|
"test:integration:selenium-webdriver-chrome": "node . --capabilities --browser $/selenium-webdriver.js -- --browser chrome",
|
|
24
24
|
"test:integration:jsdom": "node . --capabilities --browser $/jsdom.js",
|
|
25
|
+
"test:integration:playwright": "node . --capabilities --browser $/playwright.js",
|
|
25
26
|
"test:report": "node ./src/defaults/report.js ./test/report && reserve --config ./test/report/reserve.json",
|
|
26
27
|
"build:doc": "node build/doc"
|
|
27
28
|
},
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { InvalidArgumentError } = require('commander')
|
|
4
|
+
const { join } = require('path')
|
|
5
|
+
|
|
6
|
+
let browser
|
|
7
|
+
let context
|
|
8
|
+
let page
|
|
9
|
+
|
|
10
|
+
function browserSelector (value, defaultValue) {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return 'chromium'
|
|
13
|
+
}
|
|
14
|
+
if (!['chromium', 'firefox', 'webkit'].includes(value)) {
|
|
15
|
+
throw new InvalidArgumentError('Browser name')
|
|
16
|
+
}
|
|
17
|
+
return value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
require('./browser')({
|
|
21
|
+
metadata: {
|
|
22
|
+
name: 'playwright',
|
|
23
|
+
options: [
|
|
24
|
+
['-b, --browser <name>', 'Browser driver', browserSelector, 'chromium'],
|
|
25
|
+
['--visible [flag]', 'Show the browser', false],
|
|
26
|
+
['-w, --viewport-width <width>', 'Viewport width', 1280],
|
|
27
|
+
['-h, --viewport-height <height>', 'Viewport height', 720],
|
|
28
|
+
['-l, --language <lang>', 'Language', 'en-US'],
|
|
29
|
+
['-u, --unsecure', 'Disable security features', false],
|
|
30
|
+
['-v, --video', 'Record video', false],
|
|
31
|
+
['-n, --har', 'Record network activity with har file', false]
|
|
32
|
+
],
|
|
33
|
+
capabilities: {
|
|
34
|
+
modules: ['playwright'],
|
|
35
|
+
screenshot: '.png',
|
|
36
|
+
scripts: true,
|
|
37
|
+
traces: ['console', 'network']
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async screenshot ({ filename }) {
|
|
42
|
+
if (page) {
|
|
43
|
+
await page.screenshot({
|
|
44
|
+
path: filename,
|
|
45
|
+
fullPage: true
|
|
46
|
+
})
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
async beforeExit () {
|
|
52
|
+
if (page) {
|
|
53
|
+
await page.close()
|
|
54
|
+
}
|
|
55
|
+
if (context) {
|
|
56
|
+
await context.close()
|
|
57
|
+
}
|
|
58
|
+
if (browser) {
|
|
59
|
+
await browser.close()
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
async run ({
|
|
64
|
+
settings: { url, scripts, modules, dir },
|
|
65
|
+
options,
|
|
66
|
+
consoleWriter,
|
|
67
|
+
networkWriter
|
|
68
|
+
}) {
|
|
69
|
+
const browsers = require(modules.playwright)
|
|
70
|
+
browser = await browsers[options.browser].launch()
|
|
71
|
+
|
|
72
|
+
let recordVideo
|
|
73
|
+
if (options.video) {
|
|
74
|
+
recordVideo = {
|
|
75
|
+
dir
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let recordHar
|
|
80
|
+
if (options.har) {
|
|
81
|
+
recordHar = {
|
|
82
|
+
path: join(dir, 'network.har')
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
context = await browser.newContext({
|
|
87
|
+
viewport: {
|
|
88
|
+
width: options.viewportWidth,
|
|
89
|
+
height: options.viewportHeight
|
|
90
|
+
},
|
|
91
|
+
locale: options.language,
|
|
92
|
+
bypassCSP: options.unsecure,
|
|
93
|
+
ignoreHTTPSErrors: options.unsecure,
|
|
94
|
+
recordVideo,
|
|
95
|
+
recordHar
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
context.setDefaultNavigationTimeout(0)
|
|
99
|
+
|
|
100
|
+
if (scripts && scripts.length) {
|
|
101
|
+
for (const content of scripts) {
|
|
102
|
+
await context.addInitScript({ content })
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
page = await context.newPage()
|
|
107
|
+
|
|
108
|
+
page
|
|
109
|
+
.on('console', message => consoleWriter.append({
|
|
110
|
+
type: message.type(),
|
|
111
|
+
text: message.text()
|
|
112
|
+
}))
|
|
113
|
+
.on('response', response => {
|
|
114
|
+
const request = response.request()
|
|
115
|
+
networkWriter.append({
|
|
116
|
+
method: request.method(),
|
|
117
|
+
url: response.url(),
|
|
118
|
+
status: response.status()
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
await page.goto(url)
|
|
123
|
+
}
|
|
124
|
+
})
|