@vitest/runner 3.2.2 → 3.2.4

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.
@@ -1,6 +1,7 @@
1
- import { isObject, createDefer, toArray, isNegativeNaN, format, objectAttr, objDisplay, shuffle, getSafeTimers, assertTypes } from '@vitest/utils';
1
+ import { isObject, createDefer, toArray, isNegativeNaN, format, objectAttr, objDisplay, getSafeTimers, shuffle, assertTypes } from '@vitest/utils';
2
2
  import { parseSingleStack } from '@vitest/utils/source-map';
3
3
  import { processError } from '@vitest/utils/error';
4
+ import { stripLiteral } from 'strip-literal';
4
5
  import { relative } from 'pathe';
5
6
 
6
7
  class PendingError extends Error {
@@ -283,9 +284,9 @@ function resolveDeps(fixtures, depSet = new Set(), pendingFixtures = []) {
283
284
  return pendingFixtures;
284
285
  }
285
286
  function getUsedProps(fn) {
286
- let fnString = fn.toString();
287
+ let fnString = stripLiteral(fn.toString());
287
288
  // match lowered async function and strip it off
288
- // example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9Cn0
289
+ // example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9LAoKICBoMTogYXN5bmMgKCkgPT4ge30sCiAgLy8gY29tbWVudCBiZXR3ZWVuCiAgaDI6IGFzeW5jIChhKSA9PiB7fSwKfQ
289
290
  // __async(this, null, function*
290
291
  // __async(this, arguments, function*
291
292
  // __async(this, [_0, _1], function*
@@ -895,14 +896,17 @@ function createTaskCollector(fn, context) {
895
896
  };
896
897
  taskFn.extend = function(fixtures) {
897
898
  const _context = mergeContextFixtures(fixtures, context || {}, runner);
898
- return createTest(function fn(name, optionsOrFn, optionsOrTest) {
899
+ const originalWrapper = fn;
900
+ return createTest(function(name, optionsOrFn, optionsOrTest) {
899
901
  const collector = getCurrentSuite();
900
902
  const scopedFixtures = collector.fixtures();
901
903
  const context = { ...this };
902
904
  if (scopedFixtures) {
903
905
  context.fixtures = mergeScopedFixtures(context.fixtures || [], scopedFixtures);
904
906
  }
905
- collector.test.fn.call(context, formatName(name), optionsOrFn, optionsOrTest);
907
+ const { handler, options } = parseArguments(optionsOrFn, optionsOrTest);
908
+ const timeout = options.timeout ?? (runner === null || runner === void 0 ? void 0 : runner.config.testTimeout);
909
+ originalWrapper.call(context, formatName(name), handler, timeout);
906
910
  }, _context);
907
911
  };
908
912
  const _test = createChainable([
@@ -1357,6 +1361,7 @@ function getTestName(task, separator = " > ") {
1357
1361
 
1358
1362
  const now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
1359
1363
  const unixNow = Date.now;
1364
+ const { clearTimeout, setTimeout } = getSafeTimers();
1360
1365
  function updateSuiteHookState(task, name, state, runner) {
1361
1366
  if (!task.result) {
1362
1367
  task.result = { state: "run" };
@@ -1475,12 +1480,17 @@ async function finishSendTasksUpdate(runner) {
1475
1480
  }
1476
1481
  function throttle(fn, ms) {
1477
1482
  let last = 0;
1478
- return function(...args) {
1483
+ let pendingCall;
1484
+ return function call(...args) {
1479
1485
  const now = unixNow();
1480
1486
  if (now - last > ms) {
1481
1487
  last = now;
1488
+ clearTimeout(pendingCall);
1489
+ pendingCall = undefined;
1482
1490
  return fn.apply(this, args);
1483
1491
  }
1492
+ // Make sure fn is still called even if there are no further calls
1493
+ pendingCall ?? (pendingCall = setTimeout(() => call.bind(this)(...args), ms));
1484
1494
  };
1485
1495
  }
1486
1496
  // throttle based on summary reporter's DURATION_UPDATE_INTERVAL_MS
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export { a as afterAll, b as afterEach, c as beforeAll, d as beforeEach, p as co
2
2
  export { processError } from '@vitest/utils/error';
3
3
  import '@vitest/utils';
4
4
  import '@vitest/utils/source-map';
5
+ import 'strip-literal';
5
6
  import 'pathe';
package/dist/utils.js CHANGED
@@ -2,4 +2,5 @@ export { v as calculateSuiteHash, r as createChainable, w as createFileTask, x a
2
2
  import '@vitest/utils';
3
3
  import '@vitest/utils/source-map';
4
4
  import '@vitest/utils/error';
5
+ import 'strip-literal';
5
6
  import 'pathe';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "3.2.2",
4
+ "version": "3.2.4",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -39,7 +39,8 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "pathe": "^2.0.3",
42
- "@vitest/utils": "3.2.2"
42
+ "strip-literal": "^3.0.0",
43
+ "@vitest/utils": "3.2.4"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "rimraf dist && rollup -c",