@vitest/utils 2.0.0-beta.3 → 2.0.0-beta.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.
@@ -46,10 +46,14 @@ function getColors() {
46
46
  function createColors(isTTY = false) {
47
47
  const enabled = typeof process !== "undefined" && !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && !("GITHUB_ACTIONS" in process.env) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || isTTY && process.env.TERM !== "dumb" || "CI" in process.env);
48
48
  const replaceClose = (string2, close, replace, index) => {
49
- const start = string2.substring(0, index) + replace;
50
- const end = string2.substring(index + close.length);
51
- const nextIndex = end.indexOf(close);
52
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
49
+ let result = "";
50
+ let cursor = 0;
51
+ do {
52
+ result += string2.substring(cursor, index) + replace;
53
+ cursor = index + close.length;
54
+ index = string2.indexOf(close, cursor);
55
+ } while (~index);
56
+ return result + string2.substring(cursor);
53
57
  };
54
58
  const formatter = (open, close, replace = open) => {
55
59
  const fn = (input) => {
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ function shuffle(array, seed = RealDate.now()) {
69
69
  }
70
70
 
71
71
  function createSimpleStackTrace(options) {
72
- const { message = "error", stackTraceLimit = 1 } = options || {};
72
+ const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {};
73
73
  const limit = Error.stackTraceLimit;
74
74
  const prepareStackTrace = Error.prepareStackTrace;
75
75
  Error.stackTraceLimit = stackTraceLimit;
@@ -773,7 +773,12 @@ const stackIgnorePatterns = [
773
773
  "/node_modules/chai/",
774
774
  "/node_modules/tinypool/",
775
775
  "/node_modules/tinyspy/",
776
+ // browser related deps
776
777
  "/deps/chai.js",
778
+ "/deps/vitest___chai.js",
779
+ "/deps/p-limit.js",
780
+ /node:\w+/,
781
+ /__vitest_test__/,
777
782
  /__vitest_browser__/
778
783
  ];
779
784
  function extractLocation(urlLike) {
@@ -789,7 +794,8 @@ function extractLocation(urlLike) {
789
794
  url = urlObj.pathname;
790
795
  }
791
796
  if (url.startsWith("/@fs/")) {
792
- url = url.slice(typeof process !== "undefined" && process.platform === "win32" ? 5 : 4);
797
+ const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
798
+ url = url.slice(isWindows ? 5 : 4);
793
799
  }
794
800
  return [url, parts[2] || void 0, parts[3] || void 0];
795
801
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.3",
4
+ "version": "2.0.0-beta.4",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -59,7 +59,7 @@
59
59
  "dependencies": {
60
60
  "diff-sequences": "^29.6.3",
61
61
  "estree-walker": "^3.0.3",
62
- "loupe": "^3.1.0",
62
+ "loupe": "^3.1.1",
63
63
  "pretty-format": "^29.7.0"
64
64
  },
65
65
  "devDependencies": {