@vitest/browser 4.0.9 → 4.0.10

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.
@@ -23,7 +23,7 @@
23
23
  })();
24
24
  </script>
25
25
  <!-- !LOAD_METADATA! -->
26
- <script type="module" src="./assets/index-zBMt7UWw.js"></script>
26
+ <script type="module" src="./assets/index-DZIaN7GU.js"></script>
27
27
  <link rel="stylesheet" href="./assets/index-VPnwgb7M.css">
28
28
  </head>
29
29
  <body>
@@ -25,7 +25,7 @@ class IframeOrchestrator {
25
25
  const startTime = performance.now();
26
26
  this.cancelled = false;
27
27
  const config = getConfig();
28
- debug("create testers", options.files.join(", "));
28
+ debug("create testers", ...options.files.join(", "));
29
29
  const container = await getContainer(config);
30
30
  if (config.browser.ui) {
31
31
  container.className = "absolute origin-top mt-[8px]";
@@ -45,7 +45,7 @@ class IframeOrchestrator {
45
45
  return;
46
46
  }
47
47
  const file = options.files[i];
48
- debug("create iframe", file);
48
+ debug("create iframe", file.filepath);
49
49
  await this.runIsolatedTestInIframe(
50
50
  container,
51
51
  file,
@@ -2051,24 +2051,24 @@ async function prepareTestEnvironment(options) {
2051
2051
  };
2052
2052
  }
2053
2053
  let preparedData;
2054
- async function executeTests(method, files) {
2054
+ async function executeTests(method, specifications) {
2055
2055
  if (!preparedData) {
2056
2056
  throw new Error(`Data was not properly initialized. This is a bug in Vitest. Please, open a new issue with reproduction.`);
2057
2057
  }
2058
2058
  debug == null ? void 0 : debug("runner resolved successfully");
2059
2059
  const { runner, state } = preparedData;
2060
- state.ctx.files = files;
2060
+ state.ctx.files = specifications;
2061
2061
  runner.setMethod(method);
2062
2062
  const version = url.searchParams.get("browserv") || "";
2063
- files.forEach(({ filepath }) => {
2063
+ specifications.forEach(({ filepath }) => {
2064
2064
  const currentVersion = browserHashMap.get(filepath);
2065
2065
  if (!currentVersion || currentVersion[1] !== version) {
2066
2066
  browserHashMap.set(filepath, version);
2067
2067
  }
2068
2068
  });
2069
- debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
2070
- for (const file of files) {
2069
+ for (const file of specifications) {
2071
2070
  state.filepath = file.filepath;
2071
+ debug == null ? void 0 : debug("running test file", file.filepath);
2072
2072
  if (method === "run") {
2073
2073
  await startTests([file], runner);
2074
2074
  } else {
@@ -26,7 +26,7 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-CFVVvVT1.js"></script>
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-8U3FyXSU.js"></script>
30
30
  <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-uxqdqUz8.js">
31
31
  </head>
32
32
  <body>
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vitest Browser Tester</title>
8
- <script type="module" crossorigin src="/__vitest_browser__/tester-BLe1dg8x.js"></script>
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-BH1P33_v.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-uxqdqUz8.js">
10
10
  </head>
11
11
  <body>
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { PNG } from 'pngjs';
18
18
  import pm from 'pixelmatch';
19
19
  import { WebSocketServer } from 'ws';
20
20
 
21
- var version = "4.0.9";
21
+ var version = "4.0.10";
22
22
 
23
23
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
24
24
  function normalizeWindowsPath(input = "") {
@@ -2027,7 +2027,7 @@ const defaultOptions$1 = {
2027
2027
  diffColorAlt: undefined,
2028
2028
  diffMask: false
2029
2029
  };
2030
- const pixelmatch = (reference, actual, { createDiff,...options }) => {
2030
+ const pixelmatch = (reference, actual, { createDiff, ...options }) => {
2031
2031
  if (reference.metadata.height !== actual.metadata.height || reference.metadata.width !== actual.metadata.width) {
2032
2032
  return {
2033
2033
  pass: false,
@@ -3029,7 +3029,23 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3029
3029
  },
3030
3030
  getBrowserFileSourceMap(id) {
3031
3031
  const mod = globalServer.vite.moduleGraph.getModuleById(id);
3032
- return mod?.transformResult?.map;
3032
+ const result = mod?.transformResult;
3033
+ // this can happen for bundled dependencies in node_modules/.vite
3034
+ if (result && !result.map) {
3035
+ const sourceMapUrl = retrieveSourceMapURL(result.code);
3036
+ if (!sourceMapUrl) {
3037
+ return null;
3038
+ }
3039
+ const filepathDir = dirname(id);
3040
+ const sourceMapPath = resolve(filepathDir, sourceMapUrl);
3041
+ try {
3042
+ const map = JSON.parse(readFileSync(sourceMapPath, "utf-8"));
3043
+ return map;
3044
+ } catch {
3045
+ return null;
3046
+ }
3047
+ }
3048
+ return result?.map;
3033
3049
  },
3034
3050
  cancelCurrentRun(reason) {
3035
3051
  vitest.cancelCurrentRun(reason);
@@ -3152,6 +3168,20 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3152
3168
  return rpc;
3153
3169
  }
3154
3170
  }
3171
+ function retrieveSourceMapURL(source) {
3172
+ const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
3173
+ // keep executing the search to find the *last* sourceMappingURL to avoid
3174
+ // picking up sourceMappingURLs from comments, strings, etc.
3175
+ let lastMatch, match;
3176
+ // eslint-disable-next-line no-cond-assign
3177
+ while (match = re.exec(source)) {
3178
+ lastMatch = match;
3179
+ }
3180
+ if (!lastMatch) {
3181
+ return null;
3182
+ }
3183
+ return lastMatch[1];
3184
+ }
3155
3185
  // Serialization support utils.
3156
3186
  function cloneByOwnProperties(value) {
3157
3187
  // Clones the value's properties into a new Object. The simpler approach of
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "4.0.9",
4
+ "version": "4.0.10",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -51,7 +51,7 @@
51
51
  "providers"
52
52
  ],
53
53
  "peerDependencies": {
54
- "vitest": "4.0.9"
54
+ "vitest": "4.0.10"
55
55
  },
56
56
  "dependencies": {
57
57
  "magic-string": "^0.30.21",
@@ -60,8 +60,8 @@
60
60
  "sirv": "^3.0.2",
61
61
  "tinyrainbow": "^3.0.3",
62
62
  "ws": "^8.18.3",
63
- "@vitest/mocker": "4.0.9",
64
- "@vitest/utils": "4.0.9"
63
+ "@vitest/mocker": "4.0.10",
64
+ "@vitest/utils": "4.0.10"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@testing-library/user-event": "^14.6.1",
@@ -72,8 +72,8 @@
72
72
  "ivya": "^1.7.0",
73
73
  "mime": "^4.1.0",
74
74
  "pathe": "^2.0.3",
75
- "vitest": "4.0.9",
76
- "@vitest/runner": "4.0.9"
75
+ "@vitest/runner": "4.0.10",
76
+ "vitest": "4.0.10"
77
77
  },
78
78
  "scripts": {
79
79
  "typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",