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.

jestAdapter.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. 'use strict';
  2. var _jestUtil = require('jest-util');
  3. /**
  4. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. const FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
  10. const jestAdapter = async (
  11. globalConfig,
  12. config,
  13. environment,
  14. runtime,
  15. testPath,
  16. sendMessageToJest
  17. ) => {
  18. const {initialize, runAndTransformResultsToJestFormat} =
  19. runtime.requireInternalModule(FRAMEWORK_INITIALIZER);
  20. const {globals, snapshotState} = await initialize({
  21. config,
  22. environment,
  23. globalConfig,
  24. localRequire: runtime.requireModule.bind(runtime),
  25. parentProcess: process,
  26. sendMessageToJest,
  27. setGlobalsForRuntime: runtime.setGlobalsForRuntime.bind(runtime),
  28. testPath
  29. });
  30. if (config.timers === 'fake' || config.timers === 'modern') {
  31. // during setup, this cannot be null (and it's fine to explode if it is)
  32. environment.fakeTimersModern.useFakeTimers();
  33. } else if (config.timers === 'legacy') {
  34. environment.fakeTimers.useFakeTimers();
  35. }
  36. globals.beforeEach(() => {
  37. if (config.resetModules) {
  38. runtime.resetModules();
  39. }
  40. if (config.clearMocks) {
  41. runtime.clearAllMocks();
  42. }
  43. if (config.resetMocks) {
  44. runtime.resetAllMocks();
  45. if (config.timers === 'legacy') {
  46. // during setup, this cannot be null (and it's fine to explode if it is)
  47. environment.fakeTimers.useFakeTimers();
  48. }
  49. }
  50. if (config.restoreMocks) {
  51. runtime.restoreAllMocks();
  52. }
  53. });
  54. for (const path of config.setupFilesAfterEnv) {
  55. const esm = runtime.unstable_shouldLoadAsEsm(path);
  56. if (esm) {
  57. await runtime.unstable_importModule(path);
  58. } else {
  59. runtime.requireModule(path);
  60. }
  61. }
  62. const esm = runtime.unstable_shouldLoadAsEsm(testPath);
  63. if (esm) {
  64. await runtime.unstable_importModule(testPath);
  65. } else {
  66. runtime.requireModule(testPath);
  67. }
  68. const results = await runAndTransformResultsToJestFormat({
  69. config,
  70. globalConfig,
  71. testPath
  72. });
  73. _addSnapshotData(results, snapshotState); // We need to copy the results object to ensure we don't leaks the prototypes
  74. // from the VM. Jasmine creates the result objects in the parent process, we
  75. // should consider doing that for circus as well.
  76. return (0, _jestUtil.deepCyclicCopy)(results, {
  77. keepPrototype: false
  78. });
  79. };
  80. const _addSnapshotData = (results, snapshotState) => {
  81. results.testResults.forEach(({fullName, status}) => {
  82. if (status === 'pending' || status === 'failed') {
  83. // if test is skipped or failed, we don't want to mark
  84. // its snapshots as obsolete.
  85. snapshotState.markSnapshotsAsCheckedForTest(fullName);
  86. }
  87. });
  88. const uncheckedCount = snapshotState.getUncheckedCount();
  89. const uncheckedKeys = snapshotState.getUncheckedKeys();
  90. if (uncheckedCount) {
  91. snapshotState.removeUncheckedKeys();
  92. }
  93. const status = snapshotState.save();
  94. results.snapshot.fileDeleted = status.deleted;
  95. results.snapshot.added = snapshotState.added;
  96. results.snapshot.matched = snapshotState.matched;
  97. results.snapshot.unmatched = snapshotState.unmatched;
  98. results.snapshot.updated = snapshotState.updated;
  99. results.snapshot.unchecked = !status.deleted ? uncheckedCount : 0; // Copy the array to prevent memory leaks
  100. results.snapshot.uncheckedKeys = Array.from(uncheckedKeys);
  101. };
  102. module.exports = jestAdapter;