vest 5.4.1 → 5.4.2

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.
@@ -540,7 +540,7 @@ function useResetSuite() {
540
540
  vestjsRuntime.VestRuntime.reset();
541
541
  }
542
542
  function useLoadSuite(rootNode) {
543
- vestjsRuntime.VestRuntime.useLoadRootNode(rootNode);
543
+ vestjsRuntime.VestRuntime.useSetHistoryRoot(rootNode);
544
544
  useExpireSuiteResultCache();
545
545
  }
546
546
 
@@ -1415,19 +1415,6 @@ function include(fieldName) {
1415
1415
  }
1416
1416
  }
1417
1417
 
1418
- var Events;
1419
- (function (Events) {
1420
- Events["TEST_RUN_STARTED"] = "test_run_started";
1421
- Events["TEST_COMPLETED"] = "test_completed";
1422
- Events["ALL_RUNNING_TESTS_FINISHED"] = "all_running_tests_finished";
1423
- Events["REMOVE_FIELD"] = "remove_field";
1424
- Events["RESET_FIELD"] = "reset_field";
1425
- Events["RESET_SUITE"] = "reset_suite";
1426
- Events["SUITE_RUN_STARTED"] = "suite_run_started";
1427
- Events["SUITE_CALLBACK_RUN_FINISHED"] = "SUITE_CALLBACK_RUN_FINISHED";
1428
- Events["DONE_TEST_OMISSION_PASS"] = "DONE_TEST_OMISSION_PASS";
1429
- })(Events || (Events = {}));
1430
-
1431
1418
  function IsolateTest(callback, input, key) {
1432
1419
  const payload = Object.assign(Object.assign({}, IsolateTestBase()), { fieldName: input.fieldName, testFn: input.testFn });
1433
1420
  if (input.groupName) {
@@ -1571,7 +1558,11 @@ function useGetTestFromCache(dependencies, cacheAction) {
1571
1558
  cache.invalidate(dependencies);
1572
1559
  return cache(dependencies, cacheAction);
1573
1560
  }
1574
- vestjsRuntime.VestRuntime.addNodeToHistory(cachedValue);
1561
+ // FIXME(@ealush 2024-08-12): This is some kind of a hack. Instead organically letting Vest set the next
1562
+ // child of the isolate, we're forcing it from the outside.
1563
+ // Instead, an ideal solution would probably be to have test.memo be its own isolate
1564
+ // that just injects a historic output from a previous test run.
1565
+ vestjsRuntime.VestRuntime.useSetNextIsolateChild(cachedValue);
1575
1566
  return cachedValue;
1576
1567
  }
1577
1568
 
@@ -1582,7 +1573,7 @@ function vestTest(fieldName, ...args) {
1582
1573
  const groupName = useGroupName();
1583
1574
  const testObjectInput = { fieldName, groupName, message, testFn };
1584
1575
  // This invalidates the suite cache.
1585
- vestjsRuntime.Bus.useEmit(Events.TEST_RUN_STARTED);
1576
+ vestjsRuntime.Bus.useEmit('TEST_RUN_STARTED');
1586
1577
  return IsolateTest(useAttemptRunTest, testObjectInput, key);
1587
1578
  }
1588
1579
  const test = vestUtils.assign(vestTest, {
@@ -1647,7 +1638,7 @@ function useOmitOptionalFields() {
1647
1638
  runOptionalConfig(testObject);
1648
1639
  }
1649
1640
  });
1650
- vestjsRuntime.Bus.useEmit(Events.DONE_TEST_OMISSION_PASS);
1641
+ vestjsRuntime.Bus.useEmit('DONE_TEST_OMISSION_PASS');
1651
1642
  function verifyAndOmit(testObject) {
1652
1643
  const { fieldName } = VestTest.getData(testObject);
1653
1644
  if (shouldOmit.has(fieldName)) {
@@ -1689,8 +1680,8 @@ function useRunDoneCallbacks() {
1689
1680
  // eslint-disable-next-line max-statements, max-lines-per-function
1690
1681
  function useInitVestBus() {
1691
1682
  const VestBus = vestjsRuntime.Bus.useBus();
1692
- on(Events.TEST_COMPLETED, () => { });
1693
- // on(Events.TEST_RUN_STARTED, () => {});
1683
+ on('TEST_COMPLETED', () => { });
1684
+ // on("TEST_RUN_STARTED", () => {});
1694
1685
  VestBus.on(vestjsRuntime.RuntimeEvents.ISOLATE_PENDING, (isolate) => {
1695
1686
  if (VestTest.is(isolate)) {
1696
1687
  VestTest.setPending(isolate);
@@ -1699,7 +1690,7 @@ function useInitVestBus() {
1699
1690
  });
1700
1691
  VestBus.on(vestjsRuntime.RuntimeEvents.ISOLATE_DONE, (isolate) => {
1701
1692
  if (VestTest.is(isolate)) {
1702
- VestBus.emit(Events.TEST_COMPLETED, isolate);
1693
+ VestBus.emit('TEST_COMPLETED', isolate);
1703
1694
  }
1704
1695
  VestIsolate.setDone(isolate);
1705
1696
  });
@@ -1712,14 +1703,14 @@ function useInitVestBus() {
1712
1703
  }
1713
1704
  if (!SuiteWalker.useHasPending()) {
1714
1705
  // When no more async tests are running, emit the done event
1715
- VestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
1706
+ VestBus.emit('ALL_RUNNING_TESTS_FINISHED');
1716
1707
  }
1717
1708
  });
1718
- on(Events.DONE_TEST_OMISSION_PASS, () => {
1709
+ on('DONE_TEST_OMISSION_PASS', () => {
1719
1710
  /* We NEED to refresh the cache here. Don't ask */
1720
1711
  });
1721
1712
  // Called when all the tests, including async, are done running
1722
- VestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, () => {
1713
+ VestBus.on('ALL_RUNNING_TESTS_FINISHED', () => {
1723
1714
  // Small optimization. We don't need to run this if there are no async tests
1724
1715
  // The reason is that we run this function immediately after the suite callback
1725
1716
  // is run, so if the suite is only comprised of sync tests, we don't need to
@@ -1729,30 +1720,31 @@ function useInitVestBus() {
1729
1720
  }
1730
1721
  useRunDoneCallbacks();
1731
1722
  });
1732
- on(Events.RESET_FIELD, (fieldName) => {
1723
+ on('RESET_FIELD', (fieldName) => {
1733
1724
  TestWalker.resetField(fieldName);
1734
1725
  });
1735
- on(Events.SUITE_RUN_STARTED, () => {
1726
+ on('SUITE_RUN_STARTED', () => {
1736
1727
  useResetCallbacks();
1737
1728
  });
1738
- on(Events.SUITE_CALLBACK_RUN_FINISHED, () => {
1729
+ on('SUITE_CALLBACK_RUN_FINISHED', () => {
1739
1730
  if (!SuiteWalker.useHasPending()) {
1740
1731
  // When no more async tests are running, emit the done event
1741
- VestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
1732
+ VestBus.emit('ALL_RUNNING_TESTS_FINISHED');
1742
1733
  }
1743
1734
  useOmitOptionalFields();
1744
1735
  });
1745
- on(Events.REMOVE_FIELD, (fieldName) => {
1736
+ on('REMOVE_FIELD', (fieldName) => {
1746
1737
  TestWalker.removeTestByFieldName(fieldName);
1747
1738
  });
1748
- on(Events.RESET_SUITE, () => {
1739
+ on('RESET_SUITE', () => {
1749
1740
  useResetSuite();
1750
1741
  });
1751
1742
  return {
1752
1743
  subscribe,
1753
1744
  };
1754
- function subscribe(cb) {
1755
- return VestBus.on('*', () => {
1745
+ function subscribe(...args) {
1746
+ const [cb, event] = args.reverse();
1747
+ return VestBus.on(event !== null && event !== void 0 ? event : '*', () => {
1756
1748
  cb();
1757
1749
  }).off;
1758
1750
  }
@@ -1829,7 +1821,7 @@ function createSuite(...args) {
1829
1821
  return SuiteContext.run({
1830
1822
  suiteParams: args,
1831
1823
  }, () => {
1832
- vestjsRuntime.Bus.useEmit(Events.SUITE_RUN_STARTED);
1824
+ vestjsRuntime.Bus.useEmit('SUITE_RUN_STARTED');
1833
1825
  return IsolateSuite(useRunSuiteCallback(suiteCallback, ...args));
1834
1826
  }).output;
1835
1827
  }
@@ -1843,14 +1835,14 @@ function createSuite(...args) {
1843
1835
  return vestUtils.assign(
1844
1836
  // We're also binding the suite to the stateRef, so that the suite
1845
1837
  // can access the stateRef when it's called.
1846
- vestjsRuntime.VestRuntime.persist(suite), Object.assign(Object.assign({ dump: vestjsRuntime.VestRuntime.persist(() => vestjsRuntime.VestRuntime.useAvailableRoot()), get: vestjsRuntime.VestRuntime.persist(useCreateSuiteResult), remove: vestjsRuntime.Bus.usePrepareEmitter(Events.REMOVE_FIELD), reset: vestjsRuntime.Bus.usePrepareEmitter(Events.RESET_SUITE), resetField: vestjsRuntime.Bus.usePrepareEmitter(Events.RESET_FIELD), resume: vestjsRuntime.VestRuntime.persist(useLoadSuite), runStatic: (...args) => mountedStatic(...args), subscribe: VestBus.subscribe }, bindSuiteSelectors(vestjsRuntime.VestRuntime.persist(useCreateSuiteResult))), getTypedMethods()));
1838
+ vestjsRuntime.VestRuntime.persist(suite), Object.assign(Object.assign({ dump: vestjsRuntime.VestRuntime.persist(() => vestjsRuntime.VestRuntime.useAvailableRoot()), get: vestjsRuntime.VestRuntime.persist(useCreateSuiteResult), remove: vestjsRuntime.Bus.usePrepareEmitter('REMOVE_FIELD'), reset: vestjsRuntime.Bus.usePrepareEmitter('RESET_SUITE'), resetField: vestjsRuntime.Bus.usePrepareEmitter('RESET_FIELD'), resume: vestjsRuntime.VestRuntime.persist(useLoadSuite), runStatic: (...args) => mountedStatic(...args), subscribe: VestBus.subscribe }, bindSuiteSelectors(vestjsRuntime.VestRuntime.persist(useCreateSuiteResult))), getTypedMethods()));
1847
1839
  });
1848
1840
  }
1849
1841
  function useRunSuiteCallback(suiteCallback, ...args) {
1850
1842
  const emit = vestjsRuntime.Bus.useEmit();
1851
1843
  return () => {
1852
1844
  suiteCallback(...args);
1853
- emit(Events.SUITE_CALLBACK_RUN_FINISHED);
1845
+ emit('SUITE_CALLBACK_RUN_FINISHED');
1854
1846
  return useSuiteRunResult();
1855
1847
  };
1856
1848
  }