ui5-test-runner 3.1.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui5-test-runner",
3
- "version": "3.1.0",
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
  },
@@ -55,7 +56,7 @@
55
56
  "jest": "^29.5.0",
56
57
  "nock": "^13.3.1",
57
58
  "nyc": "^15.1.0",
58
- "standard": "^17.0.0"
59
+ "standard": "^17.1.0"
59
60
  },
60
61
  "optionalDependencies": {
61
62
  "fsevents": "^2.3.2"
@@ -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
+ })
@@ -93,7 +93,7 @@ require('./browser')({
93
93
  })
94
94
 
95
95
  if (scripts && scripts.length) {
96
- for await (const script of scripts) {
96
+ for (const script of scripts) {
97
97
  await page.evaluateOnNewDocument(script)
98
98
  }
99
99
  }
package/src/output.js CHANGED
@@ -9,7 +9,7 @@ const {
9
9
  $probeUrlsCompleted,
10
10
  $testPagesCompleted
11
11
  } = require('./symbols')
12
- const { noop, pad } = require('./tools')
12
+ const { filename, noop, pad } = require('./tools')
13
13
 
14
14
  const inJest = typeof jest !== 'undefined'
15
15
  const interactive = process.stdout.columns !== undefined && !inJest
@@ -305,7 +305,7 @@ function build (job) {
305
305
  },
306
306
 
307
307
  browserStart (url) {
308
- const text = p80()`${getElapsed()} >> ${pad.lt(url)}`
308
+ const text = p80()`${getElapsed()} >> ${pad.lt(url)} [${filename(url)}]`
309
309
  if (interactive) {
310
310
  output(job, text)
311
311
  } else {
@@ -319,7 +319,7 @@ function build (job) {
319
319
  if (page) {
320
320
  duration = ' (' + formatTime(page.end - page.start) + ')'
321
321
  }
322
- const text = p80()`${getElapsed()} << ${pad.lt(url + duration)}`
322
+ const text = p80()`${getElapsed()} << ${pad.lt(url)} ${duration} [${filename(url)}]`
323
323
  if (interactive) {
324
324
  output(job, text)
325
325
  } else {