ui5-test-runner 1.1.5 → 2.0.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.
Files changed (93) hide show
  1. package/README.md +32 -188
  2. package/index.js +47 -16
  3. package/package.json +28 -10
  4. package/src/add-test-pages.js +35 -0
  5. package/src/add-test-pages.spec.js +95 -0
  6. package/src/browser.spec.js +724 -0
  7. package/src/browsers.js +220 -59
  8. package/src/capabilities/index.js +194 -0
  9. package/src/capabilities/tests/basic/iframe.html +8 -0
  10. package/src/capabilities/tests/basic/index.html +12 -0
  11. package/src/capabilities/tests/basic/index.js +20 -0
  12. package/src/capabilities/tests/basic/ui5.html +24 -0
  13. package/src/capabilities/tests/dynamic-include/index.js +21 -0
  14. package/src/capabilities/tests/dynamic-include/mix.html +11 -0
  15. package/src/capabilities/tests/dynamic-include/one.html +11 -0
  16. package/src/capabilities/tests/dynamic-include/post.js +3 -0
  17. package/src/capabilities/tests/dynamic-include/test.js +1 -0
  18. package/src/capabilities/tests/dynamic-include/two.html +11 -0
  19. package/src/capabilities/tests/index.js +16 -0
  20. package/src/capabilities/tests/local-storage/index.html +16 -0
  21. package/src/capabilities/tests/local-storage/index.js +21 -0
  22. package/src/capabilities/tests/screenshot/index.html +13 -0
  23. package/src/capabilities/tests/screenshot/index.js +18 -0
  24. package/src/capabilities/tests/scripts/index.js +50 -0
  25. package/src/capabilities/tests/scripts/qunit.html +22 -0
  26. package/src/capabilities/tests/scripts/testsuite.html +10 -0
  27. package/src/capabilities/tests/scripts/testsuite.js +8 -0
  28. package/src/capabilities/tests/timeout/index.html +21 -0
  29. package/src/capabilities/tests/timeout/index.js +19 -0
  30. package/src/capabilities/tests/traces/index.html +18 -0
  31. package/src/capabilities/tests/traces/index.js +81 -0
  32. package/src/cors.js +1 -1
  33. package/src/cors.spec.js +41 -0
  34. package/src/coverage.js +30 -18
  35. package/src/coverage.spec.js +79 -0
  36. package/src/csv-reader.js +36 -0
  37. package/src/csv-reader.spec.js +42 -0
  38. package/src/csv-writer.js +52 -0
  39. package/src/csv-writer.spec.js +77 -0
  40. package/src/defaults/browser.js +144 -0
  41. package/src/defaults/jsdom/compatibility.js +95 -0
  42. package/src/defaults/jsdom/debug.js +23 -0
  43. package/src/defaults/jsdom/resource-loader.js +43 -0
  44. package/src/defaults/jsdom/sap.ui.test.matchers.visible.js +39 -0
  45. package/src/defaults/jsdom.js +64 -0
  46. package/src/defaults/junit-xml-report.js +64 -0
  47. package/src/defaults/puppeteer.js +111 -0
  48. package/src/defaults/report/common.js +38 -0
  49. package/src/defaults/report/default.html +84 -0
  50. package/src/defaults/report/main.js +44 -0
  51. package/src/defaults/report/progress.js +49 -0
  52. package/src/defaults/report/styles.css +66 -0
  53. package/src/defaults/report.js +69 -0
  54. package/src/defaults/selenium-webdriver/chrome.js +38 -0
  55. package/src/defaults/selenium-webdriver/edge.js +25 -0
  56. package/src/defaults/selenium-webdriver/firefox.js +31 -0
  57. package/src/defaults/selenium-webdriver.js +138 -0
  58. package/src/endpoints.js +70 -124
  59. package/src/error.js +52 -0
  60. package/src/error.spec.js +17 -0
  61. package/src/get-job-progress.js +69 -0
  62. package/src/get-job-progress.spec.js +175 -0
  63. package/src/inject/post.js +96 -0
  64. package/src/inject/post.spec.js +147 -0
  65. package/src/inject/qunit-hooks.js +6 -21
  66. package/src/inject/qunit-intercept.js +30 -0
  67. package/src/inject/qunit-redirect.js +15 -7
  68. package/src/job-mode.js +45 -0
  69. package/src/job.js +254 -108
  70. package/src/job.spec.js +413 -0
  71. package/src/npm.js +73 -0
  72. package/src/npm.spec.js +98 -0
  73. package/src/options.js +73 -0
  74. package/src/options.spec.js +125 -0
  75. package/src/output.js +450 -131
  76. package/src/qunit-hooks.js +116 -0
  77. package/src/qunit-hooks.spec.js +687 -0
  78. package/src/report.js +42 -0
  79. package/src/reserve.js +3 -4
  80. package/src/simulate.spec.js +437 -0
  81. package/src/symbols.js +8 -0
  82. package/src/tests.js +127 -84
  83. package/src/timeout.spec.js +39 -0
  84. package/src/tools.js +111 -4
  85. package/src/tools.spec.js +90 -0
  86. package/src/ui5.js +3 -3
  87. package/src/unhandled.js +6 -6
  88. package/src/unhandled.spec.js +63 -0
  89. package/defaults/chromium.js +0 -62
  90. package/src/progress.html +0 -71
  91. package/src/proxies.js +0 -8
  92. package/src/report.html +0 -202
  93. /package/{defaults → src/defaults}/nyc.json +0 -0
@@ -0,0 +1,116 @@
1
+ 'use strict'
2
+
3
+ const { screenshot, stop } = require('./browsers')
4
+ const { collect } = require('./coverage')
5
+ const { UTRError } = require('./error')
6
+ const { getOutput } = require('./output')
7
+ const { basename } = require('path')
8
+ const { filename, stripUrlHash } = require('./tools')
9
+
10
+ function error (job, url, details = '') {
11
+ stop(job, url)
12
+ job.failed = true
13
+ throw UTRError.QUNIT_ERROR(details)
14
+ }
15
+
16
+ function get (job, urlWithHash, testId) {
17
+ const url = stripUrlHash(urlWithHash)
18
+ const page = job.qunitPages && job.qunitPages[url]
19
+ if (!page) {
20
+ error(job, url, `No QUnit page found for ${urlWithHash}`)
21
+ }
22
+ let test
23
+ if (testId !== undefined) {
24
+ page.modules.every(module => {
25
+ test = module.tests.find(test => test.testId === testId)
26
+ return test === undefined
27
+ })
28
+ if (!test) {
29
+ error(job, url, `No QUnit unit test found with id ${testId}`)
30
+ }
31
+ }
32
+ return { url, page, test }
33
+ }
34
+
35
+ module.exports = {
36
+ get,
37
+
38
+ async begin (job, urlWithHash, { isOpa, totalTests, modules }) {
39
+ const url = stripUrlHash(urlWithHash)
40
+ if (!totalTests || !modules) {
41
+ error(job, url, 'Invalid begin hook details')
42
+ }
43
+ if (!job.qunitPages) {
44
+ job.qunitPages = {}
45
+ }
46
+ const qunitPage = {
47
+ id: filename(url),
48
+ start: new Date(),
49
+ isOpa: !!isOpa,
50
+ failed: 0,
51
+ passed: 0,
52
+ count: totalTests,
53
+ modules
54
+ }
55
+ job.qunitPages[url] = qunitPage
56
+ },
57
+
58
+ async testStart (job, urlWithHash, { module, name, testId }) {
59
+ const { test } = get(job, urlWithHash, testId)
60
+ test.start = new Date()
61
+ },
62
+
63
+ async log (job, urlWithHash, { module, name, testId, ...log }) {
64
+ const { url, page, test } = get(job, urlWithHash, testId)
65
+ if (!test.logs) {
66
+ test.logs = []
67
+ }
68
+ test.logs.push(log)
69
+ if (page.isOpa && job.browserCapabilities.screenshot && job.screenshot) {
70
+ try {
71
+ const absoluteName = await screenshot(job, url, `${testId}-${log.runtime}`)
72
+ log.screenshot = basename(absoluteName)
73
+ } catch (error) {
74
+ getOutput(job).genericError(error, url)
75
+ }
76
+ }
77
+ },
78
+
79
+ async testDone (job, urlWithHash, { name, module, testId, assertions, ...report }) {
80
+ const { failed } = report
81
+ const { url, page, test } = get(job, urlWithHash, testId)
82
+ if (failed) {
83
+ if (job.browserCapabilities.screenshot) {
84
+ try {
85
+ await screenshot(job, url, testId)
86
+ } catch (error) {
87
+ getOutput(job).genericError(error, url)
88
+ }
89
+ }
90
+ ++page.failed
91
+ job.failed = true
92
+ } else {
93
+ ++page.passed
94
+ }
95
+ test.end = new Date()
96
+ test.report = report
97
+ },
98
+
99
+ async done (job, urlWithHash, report) {
100
+ const { url, page } = get(job, urlWithHash)
101
+ if (job.browserCapabilities.screenshot) {
102
+ try {
103
+ await screenshot(job, url, 'done')
104
+ } catch (error) {
105
+ getOutput(job).genericError(error, url)
106
+ }
107
+ }
108
+ if (report.__coverage__) {
109
+ collect(job, url, report.__coverage__)
110
+ delete report.__coverage__
111
+ }
112
+ page.end = new Date()
113
+ page.report = report
114
+ stop(job, url)
115
+ }
116
+ }