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.

setup_jest_globals.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _expect = require('expect');
  7. var _jestSnapshot = require('jest-snapshot');
  8. /**
  9. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  10. *
  11. * This source code is licensed under the MIT license found in the
  12. * LICENSE file in the root directory of this source tree.
  13. */
  14. // Get suppressed errors form jest-matchers that weren't throw during
  15. // test execution and add them to the test result, potentially failing
  16. // a passing test.
  17. const addSuppressedErrors = result => {
  18. const {suppressedErrors} = (0, _expect.getState)();
  19. (0, _expect.setState)({
  20. suppressedErrors: []
  21. });
  22. if (suppressedErrors.length) {
  23. result.status = 'failed';
  24. result.failedExpectations = suppressedErrors.map(error => ({
  25. actual: '',
  26. // passing error for custom test reporters
  27. error,
  28. expected: '',
  29. matcherName: '',
  30. message: error.message,
  31. passed: false,
  32. stack: error.stack
  33. }));
  34. }
  35. };
  36. const addAssertionErrors = result => {
  37. const assertionErrors = (0, _expect.extractExpectedAssertionsErrors)();
  38. if (assertionErrors.length) {
  39. const jasmineErrors = assertionErrors.map(({actual, error, expected}) => ({
  40. actual,
  41. expected,
  42. message: error.stack,
  43. passed: false
  44. }));
  45. result.status = 'failed';
  46. result.failedExpectations = result.failedExpectations.concat(jasmineErrors);
  47. }
  48. };
  49. const patchJasmine = () => {
  50. global.jasmine.Spec = (realSpec => {
  51. class Spec extends realSpec {
  52. constructor(attr) {
  53. const resultCallback = attr.resultCallback;
  54. attr.resultCallback = function (result) {
  55. addSuppressedErrors(result);
  56. addAssertionErrors(result);
  57. resultCallback.call(attr, result);
  58. };
  59. const onStart = attr.onStart;
  60. attr.onStart = context => {
  61. (0, _expect.setState)({
  62. currentTestName: context.getFullName()
  63. });
  64. onStart && onStart.call(attr, context);
  65. };
  66. super(attr);
  67. }
  68. }
  69. return Spec;
  70. })(global.jasmine.Spec);
  71. };
  72. var _default = async ({config, globalConfig, localRequire, testPath}) => {
  73. // Jest tests snapshotSerializers in order preceding built-in serializers.
  74. // Therefore, add in reverse because the last added is the first tested.
  75. config.snapshotSerializers
  76. .concat()
  77. .reverse()
  78. .forEach(path => {
  79. (0, _jestSnapshot.addSerializer)(localRequire(path));
  80. });
  81. patchJasmine();
  82. const {expand, updateSnapshot} = globalConfig;
  83. const {prettierPath, snapshotFormat} = config;
  84. const snapshotResolver = await (0, _jestSnapshot.buildSnapshotResolver)(
  85. config,
  86. localRequire
  87. );
  88. const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath);
  89. const snapshotState = new _jestSnapshot.SnapshotState(snapshotPath, {
  90. expand,
  91. prettierPath,
  92. snapshotFormat,
  93. updateSnapshot
  94. }); // @ts-expect-error: snapshotState is a jest extension of `expect`
  95. (0, _expect.setState)({
  96. snapshotState,
  97. testPath
  98. }); // Return it back to the outer scope (test runner outside the VM).
  99. return snapshotState;
  100. };
  101. exports.default = _default;