Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reporter.js 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. 'use strict';
  2. var global = (function () {
  3. if (typeof globalThis !== 'undefined') {
  4. return globalThis;
  5. } else if (typeof global !== 'undefined') {
  6. return global;
  7. } else if (typeof self !== 'undefined') {
  8. return self;
  9. } else if (typeof window !== 'undefined') {
  10. return window;
  11. } else {
  12. return Function('return this')();
  13. }
  14. })();
  15. var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
  16. Object.defineProperty(exports, '__esModule', {
  17. value: true
  18. });
  19. exports.default = void 0;
  20. var _testResult = require('@jest/test-result');
  21. var _jestMessageUtil = require('jest-message-util');
  22. var global = (function () {
  23. if (typeof globalThis !== 'undefined') {
  24. return globalThis;
  25. } else if (typeof global !== 'undefined') {
  26. return global;
  27. } else if (typeof self !== 'undefined') {
  28. return self;
  29. } else if (typeof window !== 'undefined') {
  30. return window;
  31. } else {
  32. return Function('return this')();
  33. }
  34. })();
  35. var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
  36. var global = (function () {
  37. if (typeof globalThis !== 'undefined') {
  38. return globalThis;
  39. } else if (typeof global !== 'undefined') {
  40. return global;
  41. } else if (typeof self !== 'undefined') {
  42. return self;
  43. } else if (typeof window !== 'undefined') {
  44. return window;
  45. } else {
  46. return Function('return this')();
  47. }
  48. })();
  49. var jestNow = global[Symbol.for('jest-native-now')] || global.Date.now;
  50. var global = (function () {
  51. if (typeof globalThis !== 'undefined') {
  52. return globalThis;
  53. } else if (typeof global !== 'undefined') {
  54. return global;
  55. } else if (typeof self !== 'undefined') {
  56. return self;
  57. } else if (typeof window !== 'undefined') {
  58. return window;
  59. } else {
  60. return Function('return this')();
  61. }
  62. })();
  63. var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
  64. var global = (function () {
  65. if (typeof globalThis !== 'undefined') {
  66. return globalThis;
  67. } else if (typeof global !== 'undefined') {
  68. return global;
  69. } else if (typeof self !== 'undefined') {
  70. return self;
  71. } else if (typeof window !== 'undefined') {
  72. return window;
  73. } else {
  74. return Function('return this')();
  75. }
  76. })();
  77. var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
  78. function _defineProperty(obj, key, value) {
  79. if (key in obj) {
  80. Object.defineProperty(obj, key, {
  81. value: value,
  82. enumerable: true,
  83. configurable: true,
  84. writable: true
  85. });
  86. } else {
  87. obj[key] = value;
  88. }
  89. return obj;
  90. }
  91. class Jasmine2Reporter {
  92. constructor(globalConfig, config, testPath) {
  93. _defineProperty(this, '_testResults', void 0);
  94. _defineProperty(this, '_globalConfig', void 0);
  95. _defineProperty(this, '_config', void 0);
  96. _defineProperty(this, '_currentSuites', void 0);
  97. _defineProperty(this, '_resolve', void 0);
  98. _defineProperty(this, '_resultsPromise', void 0);
  99. _defineProperty(this, '_startTimes', void 0);
  100. _defineProperty(this, '_testPath', void 0);
  101. this._globalConfig = globalConfig;
  102. this._config = config;
  103. this._testPath = testPath;
  104. this._testResults = [];
  105. this._currentSuites = [];
  106. this._resolve = null;
  107. this._resultsPromise = new Promise(resolve => (this._resolve = resolve));
  108. this._startTimes = new Map();
  109. }
  110. jasmineStarted(_runDetails) {}
  111. specStarted(spec) {
  112. this._startTimes.set(spec.id, jestNow());
  113. }
  114. specDone(result) {
  115. this._testResults.push(
  116. this._extractSpecResults(result, this._currentSuites.slice(0))
  117. );
  118. }
  119. suiteStarted(suite) {
  120. this._currentSuites.push(suite.description);
  121. }
  122. suiteDone(_result) {
  123. this._currentSuites.pop();
  124. }
  125. jasmineDone(_runDetails) {
  126. let numFailingTests = 0;
  127. let numPassingTests = 0;
  128. let numPendingTests = 0;
  129. let numTodoTests = 0;
  130. const testResults = this._testResults;
  131. testResults.forEach(testResult => {
  132. if (testResult.status === 'failed') {
  133. numFailingTests++;
  134. } else if (testResult.status === 'pending') {
  135. numPendingTests++;
  136. } else if (testResult.status === 'todo') {
  137. numTodoTests++;
  138. } else {
  139. numPassingTests++;
  140. }
  141. });
  142. const testResult = {
  143. ...(0, _testResult.createEmptyTestResult)(),
  144. console: null,
  145. failureMessage: (0, _jestMessageUtil.formatResultsErrors)(
  146. testResults,
  147. this._config,
  148. this._globalConfig,
  149. this._testPath
  150. ),
  151. numFailingTests,
  152. numPassingTests,
  153. numPendingTests,
  154. numTodoTests,
  155. snapshot: {
  156. added: 0,
  157. fileDeleted: false,
  158. matched: 0,
  159. unchecked: 0,
  160. unmatched: 0,
  161. updated: 0
  162. },
  163. testFilePath: this._testPath,
  164. testResults
  165. };
  166. this._resolve(testResult);
  167. }
  168. getResults() {
  169. return this._resultsPromise;
  170. }
  171. _addMissingMessageToStack(stack, message) {
  172. // Some errors (e.g. Angular injection error) don't prepend error.message
  173. // to stack, instead the first line of the stack is just plain 'Error'
  174. const ERROR_REGEX = /^Error:?\s*\n/;
  175. if (stack && message && !stack.includes(message)) {
  176. return message + stack.replace(ERROR_REGEX, '\n');
  177. }
  178. return stack;
  179. }
  180. _extractSpecResults(specResult, ancestorTitles) {
  181. const start = this._startTimes.get(specResult.id);
  182. const duration = start ? jestNow() - start : undefined;
  183. const status =
  184. specResult.status === 'disabled' ? 'pending' : specResult.status;
  185. const location = specResult.__callsite
  186. ? {
  187. column: specResult.__callsite.getColumnNumber(),
  188. line: specResult.__callsite.getLineNumber()
  189. }
  190. : null;
  191. const results = {
  192. ancestorTitles,
  193. duration,
  194. failureDetails: [],
  195. failureMessages: [],
  196. fullName: specResult.fullName,
  197. location,
  198. numPassingAsserts: 0,
  199. // Jasmine2 only returns an array of failed asserts.
  200. status,
  201. title: specResult.description
  202. };
  203. specResult.failedExpectations.forEach(failed => {
  204. const message =
  205. !failed.matcherName && typeof failed.stack === 'string'
  206. ? this._addMissingMessageToStack(failed.stack, failed.message)
  207. : failed.message || '';
  208. results.failureMessages.push(message);
  209. results.failureDetails.push(failed);
  210. });
  211. return results;
  212. }
  213. }
  214. exports.default = Jasmine2Reporter;