ui5-test-runner 5.13.1 → 6.0.0-beta.2

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.
Files changed (186) hide show
  1. package/README.md +3 -2
  2. package/dist/Npm.js +80 -0
  3. package/dist/browsers/IBrowser.js +1 -0
  4. package/dist/browsers/factory.js +9 -0
  5. package/dist/browsers/puppeteer.js +158 -0
  6. package/dist/cli.js +20 -0
  7. package/dist/configuration/CommandLine.js +112 -0
  8. package/dist/configuration/Configuration.js +1 -0
  9. package/dist/configuration/ConfigurationValidator.js +79 -0
  10. package/dist/configuration/Option.js +1 -0
  11. package/dist/configuration/OptionValidationError.js +15 -0
  12. package/dist/configuration/indexedOptions.js +13 -0
  13. package/dist/configuration/options.js +191 -0
  14. package/dist/configuration/validators/OptionValidator.js +1 -0
  15. package/dist/configuration/validators/boolean.js +15 -0
  16. package/dist/configuration/validators/browser.js +11 -0
  17. package/dist/configuration/validators/fsEntry.js +70 -0
  18. package/dist/configuration/validators/index.js +20 -0
  19. package/dist/configuration/validators/integer.js +10 -0
  20. package/dist/configuration/validators/percent.js +17 -0
  21. package/dist/configuration/validators/regexp.js +20 -0
  22. package/dist/configuration/validators/string.js +7 -0
  23. package/dist/configuration/validators/timeout.js +24 -0
  24. package/dist/configuration/validators/url.js +8 -0
  25. package/dist/modes/ModeFunction.js +1 -0
  26. package/dist/modes/Modes.js +9 -0
  27. package/dist/modes/execute.js +27 -0
  28. package/dist/modes/help.js +3 -0
  29. package/dist/modes/log/ILogStorage.js +1 -0
  30. package/dist/modes/log/LogMetrics.js +9 -0
  31. package/dist/modes/log/LogReader.js +37 -0
  32. package/dist/modes/log/LogStorage.js +68 -0
  33. package/dist/modes/log/REserve.js +101 -0
  34. package/dist/modes/log/index.js +58 -0
  35. package/dist/modes/test/REserve.js +31 -0
  36. package/dist/modes/test/agent.js +8 -0
  37. package/dist/modes/test/browser.js +37 -0
  38. package/dist/modes/test/index.js +66 -0
  39. package/dist/modes/test/pageTask.js +145 -0
  40. package/dist/modes/test/report.js +3 -0
  41. package/dist/modes/test/server.js +109 -0
  42. package/dist/modes/version.js +11 -0
  43. package/dist/platform/Exit.js +139 -0
  44. package/dist/platform/FileSystem.js +13 -0
  45. package/dist/platform/Host.js +10 -0
  46. package/dist/platform/Http.js +38 -0
  47. package/dist/platform/Path.js +5 -0
  48. package/dist/platform/Process.js +133 -0
  49. package/dist/platform/Terminal.js +47 -0
  50. package/dist/platform/Thread.js +43 -0
  51. package/dist/platform/ZLib.js +7 -0
  52. package/dist/platform/assert.js +17 -0
  53. package/dist/platform/constants.js +5 -0
  54. package/dist/platform/environment.js +28 -0
  55. package/dist/platform/index.js +13 -0
  56. package/dist/platform/logger/ILogger.js +1 -0
  57. package/dist/platform/logger/allCompressed.js +54 -0
  58. package/dist/platform/logger/compress.js +277 -0
  59. package/dist/platform/logger/output/BaseLoggerOutput.js +158 -0
  60. package/dist/platform/logger/output/InteractiveLoggerOutput.js +102 -0
  61. package/dist/platform/logger/output/StaticLoggerOutput.js +32 -0
  62. package/dist/platform/logger/output/factory.js +10 -0
  63. package/dist/platform/logger/output.js +58 -0
  64. package/dist/platform/logger/proxy.js +6 -0
  65. package/dist/platform/logger/toInternalLogAttributes.js +22 -0
  66. package/dist/platform/logger/types.js +7 -0
  67. package/dist/platform/logger.js +138 -0
  68. package/dist/platform/mock.js +104 -0
  69. package/dist/platform/version.js +8 -0
  70. package/dist/platform/workerBootstrap.js +21 -0
  71. package/dist/reports/html.js +46 -0
  72. package/dist/types/AgentState.js +1 -0
  73. package/dist/types/CommonTestReportFormat.js +50 -0
  74. package/dist/types/IError.js +1 -0
  75. package/dist/types/IUserInterfaceController.js +1 -0
  76. package/dist/types/typeUtilities.js +1 -0
  77. package/dist/ui/agent.js +3 -0
  78. package/dist/ui/html-report.js +2 -0
  79. package/dist/ui/lib.js +1 -0
  80. package/dist/ui/log-viewer.js +2 -0
  81. package/dist/utils/node/Folder.js +28 -0
  82. package/dist/utils/node/FramedStreamReader.js +86 -0
  83. package/dist/utils/node/FramedStreamWriter.js +27 -0
  84. package/dist/utils/shared/ProgressBar.js +43 -0
  85. package/dist/utils/shared/TestReportBuilder.js +48 -0
  86. package/dist/utils/shared/memoize.js +19 -0
  87. package/dist/utils/shared/object.js +8 -0
  88. package/dist/utils/shared/parallelize.js +59 -0
  89. package/dist/utils/shared/string.js +23 -0
  90. package/dist/utils/shared/toIError.js +17 -0
  91. package/package.json +73 -50
  92. package/.releaserc +0 -5
  93. package/index.js +0 -175
  94. package/jest.config.json +0 -31
  95. package/src/add-test-pages.js +0 -67
  96. package/src/batch.js +0 -214
  97. package/src/browsers.js +0 -319
  98. package/src/capabilities/index.js +0 -204
  99. package/src/capabilities/tests/basic/iframe.html +0 -8
  100. package/src/capabilities/tests/basic/index.html +0 -12
  101. package/src/capabilities/tests/basic/index.js +0 -20
  102. package/src/capabilities/tests/basic/ui5.html +0 -24
  103. package/src/capabilities/tests/dynamic-include/index.js +0 -21
  104. package/src/capabilities/tests/dynamic-include/mix.html +0 -11
  105. package/src/capabilities/tests/dynamic-include/one.html +0 -11
  106. package/src/capabilities/tests/dynamic-include/post.js +0 -3
  107. package/src/capabilities/tests/dynamic-include/test.js +0 -1
  108. package/src/capabilities/tests/dynamic-include/two.html +0 -11
  109. package/src/capabilities/tests/index.js +0 -16
  110. package/src/capabilities/tests/local-storage/index.html +0 -16
  111. package/src/capabilities/tests/local-storage/index.js +0 -21
  112. package/src/capabilities/tests/screenshot/index.html +0 -23
  113. package/src/capabilities/tests/screenshot/index.js +0 -24
  114. package/src/capabilities/tests/scripts/coverage.html +0 -32
  115. package/src/capabilities/tests/scripts/iframe.html +0 -18
  116. package/src/capabilities/tests/scripts/index.js +0 -59
  117. package/src/capabilities/tests/scripts/qunit.html +0 -22
  118. package/src/capabilities/tests/scripts/testsuite.html +0 -10
  119. package/src/capabilities/tests/scripts/testsuite.js +0 -8
  120. package/src/capabilities/tests/timeout/index.html +0 -21
  121. package/src/capabilities/tests/timeout/index.js +0 -19
  122. package/src/capabilities/tests/traces/index.html +0 -18
  123. package/src/capabilities/tests/traces/index.js +0 -81
  124. package/src/capabilities/tests/ui5/focus.html +0 -89
  125. package/src/capabilities/tests/ui5/index.js +0 -39
  126. package/src/capabilities/tests/ui5/language.html +0 -50
  127. package/src/capabilities/tests/ui5/timezone.html +0 -27
  128. package/src/clean.js +0 -22
  129. package/src/cors.js +0 -21
  130. package/src/coverage.js +0 -384
  131. package/src/csv-reader.js +0 -36
  132. package/src/csv-writer.js +0 -55
  133. package/src/defaults/.nycrc.json +0 -4
  134. package/src/defaults/browser.js +0 -217
  135. package/src/defaults/happy-dom.js +0 -123
  136. package/src/defaults/jsdom/compatibility.js +0 -163
  137. package/src/defaults/jsdom/debug.js +0 -23
  138. package/src/defaults/jsdom/resource-loader.js +0 -44
  139. package/src/defaults/jsdom/sap.ui.test.matchers.visible.js +0 -39
  140. package/src/defaults/jsdom.js +0 -95
  141. package/src/defaults/json-report.js +0 -36
  142. package/src/defaults/junit-xml-report.js +0 -90
  143. package/src/defaults/playwright.js +0 -142
  144. package/src/defaults/puppeteer.js +0 -124
  145. package/src/defaults/report/common.js +0 -38
  146. package/src/defaults/report/decompress.js +0 -19
  147. package/src/defaults/report/default.html +0 -99
  148. package/src/defaults/report/main.js +0 -69
  149. package/src/defaults/report/progress.js +0 -60
  150. package/src/defaults/report/styles.css +0 -66
  151. package/src/defaults/report.js +0 -91
  152. package/src/defaults/scan-ui5.js +0 -26
  153. package/src/defaults/selenium-webdriver/chrome.js +0 -39
  154. package/src/defaults/selenium-webdriver/edge.js +0 -24
  155. package/src/defaults/selenium-webdriver/firefox.js +0 -30
  156. package/src/defaults/selenium-webdriver.js +0 -129
  157. package/src/defaults/text-report.js +0 -108
  158. package/src/defaults/webdriverio.js +0 -80
  159. package/src/end.js +0 -62
  160. package/src/endpoints.js +0 -219
  161. package/src/error.js +0 -54
  162. package/src/get-job-progress.js +0 -78
  163. package/src/handle.js +0 -43
  164. package/src/if.js +0 -10
  165. package/src/inject/jest2qunit.js +0 -289
  166. package/src/inject/opa-iframe-coverage.js +0 -22
  167. package/src/inject/post.js +0 -141
  168. package/src/inject/qunit-hooks.js +0 -107
  169. package/src/inject/qunit-redirect.js +0 -65
  170. package/src/inject/ui5-coverage.js +0 -33
  171. package/src/job-mode.js +0 -65
  172. package/src/job.js +0 -493
  173. package/src/npm.js +0 -136
  174. package/src/options.js +0 -95
  175. package/src/output.js +0 -739
  176. package/src/parallelize.js +0 -63
  177. package/src/qunit-hooks.js +0 -219
  178. package/src/report.js +0 -89
  179. package/src/reserve.js +0 -25
  180. package/src/start.js +0 -133
  181. package/src/symbols.js +0 -8
  182. package/src/tests.js +0 -183
  183. package/src/timeout.js +0 -53
  184. package/src/tools.js +0 -179
  185. package/src/ui5.js +0 -199
  186. package/src/unhandled.js +0 -32
@@ -1,91 +0,0 @@
1
- 'use strict'
2
-
3
- const { join, isAbsolute } = require('path')
4
- const { readFile, writeFile } = require('fs').promises
5
- const zlib = require('zlib')
6
- const [,, reportDir] = process.argv
7
- const verbose = process.argv.includes('--verbose')
8
- const { resolveDependencyPath } = require('../npm.js')
9
-
10
- const log = verbose ? console.log : () => {}
11
-
12
- log('🏗 Building report...')
13
-
14
- const defaultDir = join(__dirname, 'report')
15
-
16
- async function readDefault (name) {
17
- return (await readFile(join(defaultDir, name))).toString()
18
- }
19
-
20
- async function readDependency (name) {
21
- const path = join(resolveDependencyPath(name), `dist/${name}.js`)
22
- return (await readFile(path)).toString()
23
- }
24
-
25
- function minifyJs (src) {
26
- return src
27
- .replace(/\/\*.*\*\//g, '')
28
- .replace(/\{\r?\n\s*/g, '{')
29
- .replace(/\r?\n\s*\}/g, '}')
30
- .replace(/,?\r?\n\s*\.?/g, match => {
31
- let result = ''
32
- if (match.startsWith(',')) {
33
- result = ','
34
- }
35
- if (match.endsWith('.')) {
36
- result += '.'
37
- }
38
- return result || ';'
39
- })
40
- }
41
-
42
- async function main () {
43
- const html = await readDefault('default.html')
44
- log('📦 default.html :', html.length)
45
- const styles = (await readDefault('styles.css'))
46
- .replace(/\{\r?\n\s+/g, '{')
47
- .replace(/\}(\r?\n)+/g, '} ')
48
- .replace(/;\r?\n\s*/g, ';')
49
- .replace(/(:|,)\s*/g, (_, c) => c)
50
- log('📦 styles.css :', styles.length)
51
-
52
- const punyexpr = await readDependency('punyexpr')
53
- log('📦 punyexpr :', punyexpr.length)
54
- const punybind = await readDependency('punybind')
55
- log('📦 punybind :', punybind.length)
56
- const common = minifyJs(await readDefault('common.js'))
57
- log('📦 common :', common.length)
58
- const main = minifyJs(await readDefault('main.js'))
59
- log('📦 main :', main.length)
60
-
61
- const decompress = minifyJs(await readDefault('decompress.js'))
62
- log('📦 decompress :', decompress.length)
63
- const jobPath = isAbsolute(reportDir) ? reportDir : join(process.cwd(), reportDir)
64
- log('📦 job path :', jobPath)
65
- const rawJob = require(join(jobPath, 'job.js'))
66
- const json = JSON.stringify(rawJob)
67
- log('📦 json :', json.length)
68
- const buffer = zlib.gzipSync(json)
69
- const base64 = buffer.toString('base64')
70
- log('📦 json (Gzip/b64) :', base64.length)
71
- log('📦 compression :', (100 * base64.length / json.length).toFixed(2) + '%')
72
-
73
- await writeFile(join(reportDir, 'report.html'), html
74
- .replace(/(>|\}\})\r?\n\s*</g, (_, c) => `${c}<`)
75
- .replace('<link rel="stylesheet" href="/_/report/styles.css">', `<style>${styles}</style>`)
76
- .replace('<script src="/_/punyexpr.js"></script>', `<script>${punyexpr}</script>`)
77
- .replace('<script src="/_/punybind.js"></script>', `<script>${punybind}</script>`)
78
- .replace('<script src="/_/report/common.js"></script>', `<script>${common}</script>`)
79
- .replace('<script src="/_/report/main.js"></script>', `<script>${decompress};let job={};decompress("${base64}").then(json=>{job=json;report.ready.then(update=>update({...json,elapsed:report.elapsed}))});${main}</script>`)
80
- )
81
- log('✅ generated.')
82
- }
83
-
84
- main()
85
- .catch(reason => {
86
- console.error(reason)
87
- return -1
88
- })
89
- .then((code = 0) => {
90
- process.exit(code)
91
- })
@@ -1,26 +0,0 @@
1
- module.exports = async function scanUI5 (url, onFolder, onFile) {
2
- if (url.match(/\/((?:test-)?resources\/.*)/)) {
3
- return // ignore UI5 resources
4
- }
5
- let html
6
- try {
7
- html = await (await fetch(url)).text()
8
- } catch (e) {
9
- e.url = url
10
- throw e
11
- }
12
- const items = [...html.matchAll(/<a href="([^"]+)" class="icon/ig)]
13
- .map(([_, item]) => item)
14
- .filter(item => item.endsWith('/') || item.endsWith('.js') || item.endsWith('.ts'))
15
- await onFolder(items.length)
16
- for (const item of items) {
17
- const itemUrl = new URL(item, url).toString()
18
- if (item.endsWith('/')) {
19
- await scanUI5(itemUrl, onFolder, onFile)
20
- } else if (item.endsWith('.ts')) {
21
- await onFile(itemUrl, await (await fetch(itemUrl.replace(/\.ts$/, '.js'))).text())
22
- } else {
23
- await onFile(itemUrl, await (await fetch(itemUrl + '?instrument=true')).text())
24
- }
25
- }
26
- }
@@ -1,39 +0,0 @@
1
- const { join } = require('path')
2
-
3
- module.exports = async ({
4
- seleniumWebdriver,
5
- settings,
6
- options,
7
- loggingPreferences
8
- }) => {
9
- const { Browser, Builder } = seleniumWebdriver
10
- const chrome = require(join(settings.modules['selenium-webdriver'], 'chrome'))
11
-
12
- const chromeOptions = new chrome.Options()
13
- const chromeArgs = options.chromeArgs()
14
- for (const arg of chromeArgs) {
15
- if (arg !== 'true') {
16
- chromeOptions.addArguments(arg)
17
- }
18
- }
19
- chromeOptions.setLoggingPrefs(loggingPreferences)
20
- if (options.binary) {
21
- chromeOptions.setChromeBinaryPath(options.binary)
22
- }
23
- chromeOptions.excludeSwitches('--enable-logging')
24
-
25
- const builder = new Builder()
26
- .forBrowser(Browser.CHROME)
27
- .setChromeOptions(chromeOptions)
28
-
29
- if (options.server) {
30
- builder.usingServer(options.server)
31
- }
32
-
33
- const driver = await builder.build()
34
- driver.__console__ = true
35
- driver.__addScript__ = async function (source) {
36
- return await driver.sendDevToolsCommand('Page.addScriptToEvaluateOnNewDocument', { source })
37
- }
38
- return driver
39
- }
@@ -1,24 +0,0 @@
1
- const { join } = require('path')
2
-
3
- module.exports = async ({
4
- seleniumWebdriver,
5
- settings,
6
- options,
7
- loggingPreferences
8
- }) => {
9
- const { Browser, Builder } = seleniumWebdriver
10
- const edge = require(join(settings.modules['selenium-webdriver'], 'edge'))
11
-
12
- const edgeOptions = new edge.Options()
13
- edgeOptions.setLoggingPrefs(loggingPreferences)
14
-
15
- const builder = new Builder()
16
- .forBrowser(Browser.EDGE)
17
- .setEdgeOptions(edgeOptions)
18
-
19
- if (options.server) {
20
- builder.usingServer(options.server)
21
- }
22
-
23
- return await builder.build()
24
- }
@@ -1,30 +0,0 @@
1
- const { join } = require('path')
2
-
3
- module.exports = async ({
4
- seleniumWebdriver,
5
- settings,
6
- options,
7
- loggingPreferences
8
- }) => {
9
- const { Browser, Builder } = seleniumWebdriver
10
- const firefox = require(join(settings.modules['selenium-webdriver'], 'firefox'))
11
-
12
- const firefoxOptions = new firefox.Options()
13
- if (!options.visible) {
14
- firefoxOptions.addArguments('-headless')
15
- }
16
- firefoxOptions.setLoggingPrefs(loggingPreferences)
17
- if (options.binary) {
18
- firefoxOptions.setBinary(options.binary)
19
- }
20
-
21
- const builder = new Builder()
22
- .forBrowser(Browser.FIREFOX)
23
- .setFirefoxOptions(firefoxOptions)
24
-
25
- if (options.server) {
26
- builder.usingServer(options.server)
27
- }
28
-
29
- return await builder.build()
30
- }
@@ -1,129 +0,0 @@
1
- 'use strict'
2
-
3
- const { url } = require('../options')
4
- const { writeFile } = require('fs/promises')
5
-
6
- let logging
7
- let driver
8
-
9
- async function buildDriver (settings, options) {
10
- const seleniumWebdriver = require(settings.modules['selenium-webdriver'])
11
-
12
- logging = seleniumWebdriver.logging
13
- logging.getLogger(logging.Type.BROWSER).setLevel(logging.Level.ALL)
14
-
15
- const loggingPreferences = new logging.Preferences()
16
- loggingPreferences.setLevel(logging.Type.BROWSER, logging.Level.ALL)
17
-
18
- driver = await require('./selenium-webdriver/' + options.browser)({
19
- seleniumWebdriver,
20
- settings,
21
- options,
22
- loggingPreferences
23
- })
24
- }
25
-
26
- require('./browser')({
27
- metadata: {
28
- name: 'selenium-webdriver',
29
- options: [
30
- ['browser', 'chrome', 'firefox', 'edge'],
31
- 'visible',
32
- ['-s, --server <server>', 'Selenium server URL', url],
33
- 'binary',
34
- 'unsecure'
35
- ]
36
- },
37
-
38
- async capabilities ({ settings, options }) {
39
- const capabilities = {
40
- modules: ['selenium-webdriver'],
41
- screenshot: '.png',
42
- scripts: false,
43
- traces: []
44
- }
45
- if (!settings.modules) {
46
- return {
47
- ...capabilities,
48
- 'probe-with-modules': true
49
- }
50
- }
51
- await buildDriver(settings, options)
52
- if (driver.__console__) {
53
- capabilities.traces.push('console')
54
- }
55
- if (driver.__network__) {
56
- capabilities.traces.push('network')
57
- }
58
- if (driver.__addScript__) {
59
- capabilities.scripts = true
60
- }
61
- return capabilities
62
- },
63
-
64
- async screenshot ({ filename }) {
65
- if (driver) {
66
- const data = await driver.takeScreenshot()
67
- await writeFile(filename, data.replace(/^data:image\/png;base64,/, ''), {
68
- encoding: 'base64'
69
- })
70
- return true
71
- }
72
- },
73
-
74
- async flush ({
75
- settings,
76
- consoleWriter
77
- }) {
78
- if (driver && settings.capabilities.traces.includes('console')) {
79
- const logs = await driver.manage().logs().get(logging.Type.BROWSER)
80
- const logLevelMapping = {
81
- DEBUG: 'debug',
82
- INFO: 'log',
83
- WARNING: 'warning',
84
- SEVERE: 'error'
85
- }
86
- if (logs.length) {
87
- consoleWriter.append(logs.map(({ timestamp, message, level }) => {
88
- return {
89
- timestamp,
90
- type: logLevelMapping[level.toString()],
91
- text: message
92
- }
93
- }))
94
- }
95
- }
96
- },
97
-
98
- async beforeExit () {
99
- if (driver) {
100
- await driver.quit()
101
- }
102
- },
103
-
104
- async run ({
105
- settings,
106
- options
107
- }) {
108
- await buildDriver(settings, options)
109
-
110
- const { url, scripts } = settings
111
-
112
- if (scripts && scripts.length) {
113
- for await (const script of scripts) {
114
- await driver.__addScript__(script)
115
- }
116
- }
117
-
118
- await driver.get(url)
119
- },
120
-
121
- async error ({ error: e }) {
122
- if (e.name === 'SessionNotCreatedError') {
123
- console.error(e.message)
124
- } else {
125
- console.error(e)
126
- }
127
- console.error('Please check https://www.npmjs.com/package/selenium-webdriver#installation for browser driver')
128
- }
129
- })
@@ -1,108 +0,0 @@
1
- 'use strict'
2
-
3
- const { join, isAbsolute } = require('path')
4
- const [, , reportDir, expectedWidth] = process.argv
5
- const { pad } = require('../tools')
6
-
7
- const p = pad(process.stdout.columns || parseInt(expectedWidth || '80', 10))
8
- const log = console.log.bind(console)
9
-
10
- function collectErrors (page) {
11
- const errors = []
12
- page.modules.forEach(module => {
13
- module.tests.every(test => {
14
- if (!test.report) {
15
- if (!test.skip) {
16
- test.logs ??= []
17
- test.logs.push({
18
- message: '(no report found)'
19
- })
20
- errors.push({ module: module.name, ...test })
21
- return false
22
- }
23
- } else if (test.report.failed) {
24
- errors.push({ module: module.name, ...test })
25
- }
26
- return true
27
- })
28
- })
29
- return errors
30
- }
31
-
32
- async function main () {
33
- let jobPath
34
- if (isAbsolute(reportDir)) {
35
- jobPath = join(reportDir, 'job.js')
36
- } else {
37
- jobPath = join(process.cwd(), reportDir, 'job.js')
38
- }
39
- const job = require(jobPath)
40
- const failedUrls = []
41
- let rendered = 0
42
- function render (url) {
43
- if (++rendered === 1) {
44
- log(p`┌─${pad.x('─')}───────────────────┐`)
45
- }
46
- const page = job.qunitPages && job.qunitPages[url]
47
- if (!page || !page.report) {
48
- log(p`│${pad.lt(url)} 🧨 │`)
49
- failedUrls.push(url)
50
- } else {
51
- const type = page.isOpa ? '🥼' : '🧪'
52
- const status = page.report.failed > 0 ? '🐞' : ' '
53
- if (page.report.failed > 0) {
54
- failedUrls.push(url)
55
- }
56
- log(p`│${pad.lt(url)} ${type} ${status} ${page.passed.toString().padStart(3, ' ')}/${page.count.toString().padEnd(3, ' ')}│`)
57
- }
58
- }
59
- job.testPageUrls.forEach(render)
60
- Object.keys(job.qunitPages || []).forEach(url => {
61
- if (!job.testPageUrls.includes(url)) {
62
- render(url)
63
- }
64
- })
65
- if (rendered > 0) {
66
- log(p`└─${pad.x('─')}────────────────────┘`)
67
- }
68
- failedUrls.forEach(url => {
69
- log()
70
- log(p`[${pad.lt(url)}]`)
71
- const page = job.qunitPages && job.qunitPages[url]
72
- if (!page) {
73
- log(p`Unable to run the page (check the execution log)`)
74
- } else {
75
- const pageIndex = job.testPageUrls.indexOf(url)
76
- const pageHash = job.testPageHashes[pageIndex]
77
- if (pageHash) {
78
- log(p`Page execution folder name : ${pageHash}`)
79
- }
80
- let errors = collectErrors(page)
81
- const { length } = errors
82
- if (page.isOpa) {
83
- // Focus on the first error only
84
- errors = errors.slice(0, 1)
85
- }
86
- errors.forEach((test, index) => {
87
- if (index > 0) {
88
- log()
89
- }
90
- log(`${test.module} ▶ ${test.name}`)
91
- test.logs.filter(({ result }) => !result).forEach(({ message }) => log(message))
92
- })
93
- if (page.isOpa && length > 1) {
94
- log()
95
- log(p`(${length} errors occurred but it is recommended to focus on the first OPA error)`)
96
- }
97
- }
98
- })
99
- }
100
-
101
- main()
102
- .catch(reason => {
103
- console.error(reason)
104
- return -1
105
- })
106
- .then((code = 0) => {
107
- process.exit(code)
108
- })
@@ -1,80 +0,0 @@
1
- 'use strict'
2
-
3
- let browserio
4
-
5
- require('./browser')({
6
- metadata: {
7
- name: 'webdriverio',
8
- options: [
9
- 'visible',
10
- ['browser', 'chrome', 'firefox'],
11
- 'binary',
12
- 'viewport',
13
- 'language',
14
- 'unsecure'
15
- ]
16
- },
17
-
18
- async capabilities ({ settings, options }) {
19
- return {
20
- modules: ['webdriverio'],
21
- screenshot: '.png',
22
- scripts: true,
23
- traces: []
24
- }
25
- },
26
-
27
- async screenshot ({ filename }) {
28
- if (browserio) {
29
- await browserio.saveScreenshot(filename)
30
- return true
31
- }
32
- },
33
-
34
- async beforeExit () {
35
- if (browserio) {
36
- await browserio.deleteSession()
37
- }
38
- },
39
-
40
- async run ({
41
- settings: { url, scripts, modules },
42
- options,
43
- consoleWriter,
44
- networkWriter
45
- }) {
46
- const { remote } = require(modules.webdriverio)
47
-
48
- const [browserOptions, args] = {
49
- chrome: [
50
- 'goog:chromeOptions',
51
- options.chromeArgs()
52
- ],
53
- firefox: [
54
- 'moz:firefoxOptions',
55
- options.visible ? [] : ['-headless']
56
- ]
57
- }[options.browser]
58
-
59
- browserio = await remote({
60
- capabilities: {
61
- browserName: options.browser,
62
- webSocketUrl: true,
63
- [browserOptions]: {
64
- args,
65
- binary: options.binary
66
- }
67
- }
68
- })
69
-
70
- if (scripts && scripts.length) {
71
- for (const script of scripts) {
72
- await browserio.scriptAddPreloadScript({
73
- functionDeclaration: `() => ${script}`
74
- })
75
- }
76
- }
77
-
78
- await browserio.url(url)
79
- }
80
- })
package/src/end.js DELETED
@@ -1,62 +0,0 @@
1
- const { fork } = require('node:child_process')
2
- const { join } = require('node:path')
3
- const { getOutput } = require('./output')
4
- const { allocPromise } = require('./tools')
5
-
6
- async function end (job) {
7
- const { endScript: end } = job
8
- const output = getOutput(job)
9
- const [script, ...args] = end.split(' ')
10
-
11
- job.status = 'Executing end script'
12
-
13
- output.debug('end', 'Starting script :', end)
14
- const childProcess = fork(
15
- script,
16
- [...args, join(job.reportDir, 'job.js')],
17
- {
18
- cwd: job.cwd,
19
- stdio: [0, 'pipe', 'pipe', 'ipc'],
20
- windowsHide: true,
21
- env: {
22
- ...process.env,
23
- ...job.env
24
- }
25
- }
26
- )
27
-
28
- const { promise: childProcessExit, resolve: childProcessExited } = allocPromise()
29
- childProcess.on('close', childProcessExited)
30
- output.monitor(childProcess)
31
-
32
- job.status = 'Waiting for script to end'
33
-
34
- if (job.endTimeout) {
35
- let timedOut = false
36
- const { promise: endTimeoutSignal, resolve: endTimeoutReached } = allocPromise()
37
- const timeoutId = setTimeout(() => {
38
- timedOut = true
39
- endTimeoutReached()
40
- }, job.endTimeout)
41
-
42
- await Promise.race([
43
- childProcessExit,
44
- endTimeoutSignal
45
- ])
46
- clearTimeout(timeoutId)
47
-
48
- if (timedOut) {
49
- childProcess.kill()
50
- throw new Error('Timeout while waiting for end script')
51
- }
52
- } else {
53
- await childProcessExit
54
- }
55
-
56
- output.debug('end', 'Ended with exit code :', childProcess.exitCode)
57
-
58
- // IMPORTANT : the end command CHANGES the exit code
59
- process.exitCode = childProcess.exitCode
60
- }
61
-
62
- module.exports = { end }