index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _actCompat = require("./act-compat");
  6. var _pure = require("./pure");
  7. Object.keys(_pure).forEach(function (key) {
  8. if (key === "default" || key === "__esModule") return;
  9. if (key in exports && exports[key] === _pure[key]) return;
  10. Object.defineProperty(exports, key, {
  11. enumerable: true,
  12. get: function () {
  13. return _pure[key];
  14. }
  15. });
  16. });
  17. var _process$env;
  18. // if we're running in a test runner that supports afterEach
  19. // or teardown then we'll automatically run cleanup afterEach test
  20. // this ensures that tests run in isolation from each other
  21. // if you don't like this then either import the `pure` module
  22. // or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'.
  23. if (typeof process === 'undefined' || !((_process$env = process.env) != null && _process$env.RTL_SKIP_AUTO_CLEANUP)) {
  24. // ignore teardown() in code coverage because Jest does not support it
  25. /* istanbul ignore else */
  26. if (typeof afterEach === 'function') {
  27. afterEach(() => {
  28. (0, _pure.cleanup)();
  29. });
  30. } else if (typeof teardown === 'function') {
  31. // Block is guarded by `typeof` check.
  32. // eslint does not support `typeof` guards.
  33. // eslint-disable-next-line no-undef
  34. teardown(() => {
  35. (0, _pure.cleanup)();
  36. });
  37. } // No test setup with other test runners available
  38. /* istanbul ignore else */
  39. if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
  40. // This matches the behavior of React < 18.
  41. let previousIsReactActEnvironment = (0, _actCompat.getIsReactActEnvironment)();
  42. beforeAll(() => {
  43. previousIsReactActEnvironment = (0, _actCompat.getIsReactActEnvironment)();
  44. (0, _actCompat.setReactActEnvironment)(true);
  45. });
  46. afterAll(() => {
  47. (0, _actCompat.setReactActEnvironment)(previousIsReactActEnvironment);
  48. });
  49. }
  50. }