@vitest/runner 2.1.0-beta.6 → 2.1.0

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { VitestRunner } from './types.js';
2
2
  export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
3
- import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, B as BeforeAllListener, A as AfterAllListener, h as BeforeEachListener, i as AfterEachListener, j as TaskHook, O as OnTestFailedHandler, k as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, l as SuiteHooks } from './tasks-C13WjyUB.js';
4
- export { D as DoneCallback, L as ExtendedContext, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, G as RuntimeContext, M as SequenceHooks, N as SequenceSetupFiles, E as SuiteFactory, n as TaskBase, K as TaskContext, z as TaskCustomOptions, p as TaskMeta, o as TaskPopulated, q as TaskResult, r as TaskResultPack, m as TaskState, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks-C13WjyUB.js';
3
+ import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, B as BeforeAllListener, A as AfterAllListener, h as BeforeEachListener, i as AfterEachListener, j as TaskHook, O as OnTestFailedHandler, k as OnTestFinishedHandler, a as Test, C as Custom, S as Suite, l as SuiteHooks } from './tasks--RurNSkd.js';
4
+ export { D as DoneCallback, L as ExtendedContext, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, G as RuntimeContext, M as SequenceHooks, N as SequenceSetupFiles, E as SuiteFactory, n as TaskBase, K as TaskContext, z as TaskCustomOptions, p as TaskMeta, o as TaskPopulated, q as TaskResult, r as TaskResultPack, m as TaskState, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks--RurNSkd.js';
5
5
  import { Awaitable } from '@vitest/utils';
6
6
  export { processError } from '@vitest/utils/error';
7
7
  import '@vitest/utils/diff';
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ function withTimeout(fn, timeout, isHook = false) {
56
56
  return fn;
57
57
  }
58
58
  const { setTimeout, clearTimeout } = getSafeTimers();
59
- return (...args) => {
59
+ return function runWithTimeout(...args) {
60
60
  return Promise.race([
61
61
  fn(...args),
62
62
  new Promise((resolve, reject) => {
@@ -421,7 +421,7 @@ function createSuiteCollector(name, factory = () => {
421
421
  setFn(
422
422
  task2,
423
423
  withTimeout(
424
- withFixtures(handler, context),
424
+ withAwaitAsyncAssetions(withFixtures(handler, context), task2),
425
425
  (options == null ? void 0 : options.timeout) ?? runner.config.testTimeout
426
426
  )
427
427
  );
@@ -524,6 +524,18 @@ function createSuiteCollector(name, factory = () => {
524
524
  collectTask(collector);
525
525
  return collector;
526
526
  }
527
+ function withAwaitAsyncAssetions(fn, task) {
528
+ return async (...args) => {
529
+ await fn(...args);
530
+ if (task.promises) {
531
+ const result = await Promise.allSettled(task.promises);
532
+ const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
533
+ if (errors.length) {
534
+ throw errors;
535
+ }
536
+ }
537
+ };
538
+ }
527
539
  function createSuite() {
528
540
  function suiteFn(name, factoryOrOptions, optionsOrFactory = {}) {
529
541
  const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
@@ -750,7 +762,7 @@ async function runSetupFiles(config, files, runner) {
750
762
  }
751
763
  }
752
764
 
753
- const now$1 = Date.now;
765
+ const now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
754
766
  async function collectTests(paths, runner) {
755
767
  var _a;
756
768
  const files = [];
@@ -823,7 +835,8 @@ function mergeHooks(baseHooks, hooks) {
823
835
  return baseHooks;
824
836
  }
825
837
 
826
- const now = Date.now;
838
+ const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
839
+ const unixNow = Date.now;
827
840
  function updateSuiteHookState(suite, name, state, runner) {
828
841
  var _a;
829
842
  if (!suite.result) {
@@ -933,7 +946,7 @@ async function runTest(test, runner) {
933
946
  const start = now();
934
947
  test.result = {
935
948
  state: "run",
936
- startTime: start,
949
+ startTime: unixNow(),
937
950
  retryCount: 0
938
951
  };
939
952
  updateTask(test, runner);
@@ -968,13 +981,6 @@ async function runTest(test, runner) {
968
981
  }
969
982
  await fn();
970
983
  }
971
- if (test.promises) {
972
- const result = await Promise.allSettled(test.promises);
973
- const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
974
- if (errors.length) {
975
- throw errors;
976
- }
977
- }
978
984
  await ((_d = runner.onAfterTryTask) == null ? void 0 : _d.call(runner, test, {
979
985
  retry: retryCount,
980
986
  repeats: repeatCount
@@ -1086,7 +1092,7 @@ async function runSuite(suite, runner) {
1086
1092
  const start = now();
1087
1093
  suite.result = {
1088
1094
  state: "run",
1089
- startTime: start
1095
+ startTime: unixNow()
1090
1096
  };
1091
1097
  updateTask(suite, runner);
1092
1098
  let beforeAllCleanups = [];
@@ -373,18 +373,21 @@ type SuiteAPI<ExtraContext = object> = ChainableSuiteAPI<ExtraContext> & {
373
373
  * @deprecated
374
374
  */
375
375
  type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
376
- type HookCleanupCallback = (() => Awaitable<unknown>) | void;
376
+ /**
377
+ * @deprecated
378
+ */
379
+ type HookCleanupCallback = unknown;
377
380
  interface BeforeAllListener {
378
- (suite: Readonly<Suite | File>): Awaitable<HookCleanupCallback>;
381
+ (suite: Readonly<Suite | File>): Awaitable<unknown>;
379
382
  }
380
383
  interface AfterAllListener {
381
- (suite: Readonly<Suite | File>): Awaitable<void>;
384
+ (suite: Readonly<Suite | File>): Awaitable<unknown>;
382
385
  }
383
386
  interface BeforeEachListener<ExtraContext = object> {
384
- (context: ExtendedContext<Test | Custom> & ExtraContext, suite: Readonly<Suite>): Awaitable<HookCleanupCallback>;
387
+ (context: ExtendedContext<Test | Custom> & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
385
388
  }
386
389
  interface AfterEachListener<ExtraContext = object> {
387
- (context: ExtendedContext<Test | Custom> & ExtraContext, suite: Readonly<Suite>): Awaitable<void>;
390
+ (context: ExtendedContext<Test | Custom> & ExtraContext, suite: Readonly<Suite>): Awaitable<unknown>;
388
391
  }
389
392
  interface SuiteHooks<ExtraContext = object> {
390
393
  beforeAll: BeforeAllListener[];
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as SequenceHooks, N as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, r as TaskResultPack, K as TaskContext, L as ExtendedContext } from './tasks-C13WjyUB.js';
2
- export { A as AfterAllListener, i as AfterEachListener, B as BeforeAllListener, h as BeforeEachListener, g as CustomAPI, D as DoneCallback, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, k as OnTestFinishedHandler, R as RunMode, G as RuntimeContext, d as SuiteAPI, f as SuiteCollector, E as SuiteFactory, l as SuiteHooks, n as TaskBase, z as TaskCustomOptions, j as TaskHook, p as TaskMeta, o as TaskPopulated, q as TaskResult, m as TaskState, e as TestAPI, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks-C13WjyUB.js';
1
+ import { M as SequenceHooks, N as SequenceSetupFiles, F as File, T as Task, a as Test, C as Custom, S as Suite, r as TaskResultPack, K as TaskContext, L as ExtendedContext } from './tasks--RurNSkd.js';
2
+ export { A as AfterAllListener, i as AfterEachListener, B as BeforeAllListener, h as BeforeEachListener, g as CustomAPI, D as DoneCallback, w as Fixture, v as FixtureFn, u as FixtureOptions, x as Fixtures, y as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, k as OnTestFinishedHandler, R as RunMode, G as RuntimeContext, d as SuiteAPI, f as SuiteCollector, E as SuiteFactory, l as SuiteHooks, n as TaskBase, z as TaskCustomOptions, j as TaskHook, p as TaskMeta, o as TaskPopulated, q as TaskResult, m as TaskState, e as TestAPI, J as TestContext, s as TestFunction, t as TestOptions, U as Use } from './tasks--RurNSkd.js';
3
3
  import { DiffOptions } from '@vitest/utils/diff';
4
4
  import '@vitest/utils';
5
5
 
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Suite, F as File, T as Task, a as Test, C as Custom } from './tasks-C13WjyUB.js';
2
- export { b as ChainableFunction, c as createChainable } from './tasks-C13WjyUB.js';
1
+ import { S as Suite, F as File, T as Task, a as Test, C as Custom } from './tasks--RurNSkd.js';
2
+ export { b as ChainableFunction, c as createChainable } from './tasks--RurNSkd.js';
3
3
  import { Arrayable } from '@vitest/utils';
4
4
 
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "2.1.0-beta.6",
4
+ "version": "2.1.0",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -39,7 +39,7 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "pathe": "^1.1.2",
42
- "@vitest/utils": "2.1.0-beta.6"
42
+ "@vitest/utils": "2.1.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "rimraf dist && rollup -c",