@vitest/runner 1.5.0 → 1.5.1

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -666,6 +666,16 @@ function getSuiteHooks(suite, name, sequence) {
666
666
  return hooks.slice().reverse();
667
667
  return hooks;
668
668
  }
669
+ async function callTaskHooks(task, hooks, sequence) {
670
+ if (sequence === "stack")
671
+ hooks = hooks.slice().reverse();
672
+ if (sequence === "parallel") {
673
+ await Promise.all(hooks.map((fn) => fn(task.result)));
674
+ } else {
675
+ for (const fn of hooks)
676
+ await fn(task.result);
677
+ }
678
+ }
669
679
  async function callSuiteHook(suite, currentTask, name, runner, args) {
670
680
  const sequence = runner.config.sequence.hooks;
671
681
  const callbacks = [];
@@ -727,7 +737,7 @@ async function callCleanupHooks(cleanups) {
727
737
  }));
728
738
  }
729
739
  async function runTest(test, runner) {
730
- var _a, _b, _c, _d, _e, _f, _g, _h;
740
+ var _a, _b, _c, _d, _e, _f;
731
741
  await ((_a = runner.onBeforeRunTask) == null ? void 0 : _a.call(runner, test));
732
742
  if (test.mode !== "run")
733
743
  return;
@@ -800,13 +810,13 @@ async function runTest(test, runner) {
800
810
  }
801
811
  }
802
812
  try {
803
- await Promise.all(((_f = test.onFinished) == null ? void 0 : _f.map((fn) => fn(test.result))) || []);
813
+ await callTaskHooks(test, test.onFinished || [], "stack");
804
814
  } catch (e) {
805
815
  failTask(test.result, e, runner.config.diffOptions);
806
816
  }
807
817
  if (test.result.state === "fail") {
808
818
  try {
809
- await Promise.all(((_g = test.onFailed) == null ? void 0 : _g.map((fn) => fn(test.result))) || []);
819
+ await callTaskHooks(test, test.onFailed || [], runner.config.sequence.hooks);
810
820
  } catch (e) {
811
821
  failTask(test.result, e, runner.config.diffOptions);
812
822
  }
@@ -823,7 +833,7 @@ async function runTest(test, runner) {
823
833
  }
824
834
  setCurrentTest(void 0);
825
835
  test.result.duration = now() - start;
826
- await ((_h = runner.onAfterRunTask) == null ? void 0 : _h.call(runner, test));
836
+ await ((_f = runner.onAfterRunTask) == null ? void 0 : _f.call(runner, test));
827
837
  updateTask(test, runner);
828
838
  }
829
839
  function failTask(result, err, diffOptions) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "p-limit": "^5.0.0",
42
42
  "pathe": "^1.1.1",
43
- "@vitest/utils": "1.5.0"
43
+ "@vitest/utils": "1.5.1"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "rimraf dist && rollup -c",