@vitest/runner 3.2.2 → 3.2.3

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*
@@ -1357,6 +1358,7 @@ function getTestName(task, separator = " > ") {
1357
1358
 
1358
1359
  const now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
1359
1360
  const unixNow = Date.now;
1361
+ const { clearTimeout, setTimeout } = getSafeTimers();
1360
1362
  function updateSuiteHookState(task, name, state, runner) {
1361
1363
  if (!task.result) {
1362
1364
  task.result = { state: "run" };
@@ -1475,12 +1477,17 @@ async function finishSendTasksUpdate(runner) {
1475
1477
  }
1476
1478
  function throttle(fn, ms) {
1477
1479
  let last = 0;
1478
- return function(...args) {
1480
+ let pendingCall;
1481
+ return function call(...args) {
1479
1482
  const now = unixNow();
1480
1483
  if (now - last > ms) {
1481
1484
  last = now;
1485
+ clearTimeout(pendingCall);
1486
+ pendingCall = undefined;
1482
1487
  return fn.apply(this, args);
1483
1488
  }
1489
+ // Make sure fn is still called even if there are no further calls
1490
+ pendingCall ?? (pendingCall = setTimeout(() => call.bind(this)(...args), ms));
1484
1491
  };
1485
1492
  }
1486
1493
  // 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.3",
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.3"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "rimraf dist && rollup -c",