@vitest/browser 1.6.0 → 2.0.0-beta.2

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.
@@ -17,8 +17,8 @@
17
17
  })()
18
18
  </script>
19
19
  <!-- !LOAD_METADATA! -->
20
- <script type="module" crossorigin src="./assets/index-TpLatVz2.js"></script>
21
- <link rel="stylesheet" crossorigin href="./assets/index-fUmMsp0O.css">
20
+ <script type="module" crossorigin src="./assets/index-D1SnFeL5.js"></script>
21
+ <link rel="stylesheet" crossorigin href="./assets/index-D0Wp7rbG.css">
22
22
  </head>
23
23
  <body>
24
24
  <div id="app"></div>
@@ -1,4 +1,4 @@
1
- import { c as client, g as getConfig, a as getBrowserState, b as channel, r as rpcDone } from "./rpc-slP7oy1q.js";
1
+ import { c as client, g as getConfig, a as getBrowserState, b as channel, r as rpcDone } from "./rpc-By4jD8av.js";
2
2
  const url = new URL(location.href);
3
3
  const ID_ALL = "__vitest_all__";
4
4
  const iframes = /* @__PURE__ */ new Map();
@@ -74,6 +74,8 @@ function createBirpc(functions, options) {
74
74
  get(_, method) {
75
75
  if (method === "$functions")
76
76
  return functions;
77
+ if (method === "then" && !eventNames.includes("then") && !("then" in functions))
78
+ return void 0;
77
79
  const sendEvent = (...args) => {
78
80
  post(serialize({ m: method, a: args, t: "q" }));
79
81
  };
@@ -84,11 +86,11 @@ function createBirpc(functions, options) {
84
86
  const sendCall = async (...args) => {
85
87
  await _promise;
86
88
  return new Promise((resolve2, reject) => {
87
- var _a, _b;
89
+ var _a;
88
90
  const id = nanoid();
89
91
  let timeoutId;
90
92
  if (timeout >= 0) {
91
- timeoutId = (_b = (_a = setTimeout$1(() => {
93
+ timeoutId = setTimeout$1(() => {
92
94
  var _a2;
93
95
  try {
94
96
  (_a2 = options.onTimeoutError) == null ? void 0 : _a2.call(options, method, args);
@@ -97,7 +99,9 @@ function createBirpc(functions, options) {
97
99
  reject(e);
98
100
  }
99
101
  rpcPromiseMap.delete(id);
100
- }, timeout)).unref) == null ? void 0 : _b.call(_a);
102
+ }, timeout);
103
+ if (typeof timeoutId === "object")
104
+ timeoutId = (_a = timeoutId.unref) == null ? void 0 : _a.call(timeoutId);
101
105
  }
102
106
  rpcPromiseMap.set(id, { resolve: resolve2, reject, timeoutId });
103
107
  post(serialize({ m: method, a: args, i: id, t: "q" }));
@@ -150,7 +154,6 @@ function nanoid(size = 21) {
150
154
  id += urlAlphabet[random() * 64 | 0];
151
155
  return id;
152
156
  }
153
- /*! (c) 2020 Andrea Giammarchi */
154
157
  const { parse: $parse, stringify: $stringify } = JSON;
155
158
  const { keys } = Object;
156
159
  const Primitive = String;
@@ -222,15 +225,17 @@ const stringify = (value, replacer, space) => {
222
225
  return after;
223
226
  }
224
227
  };
228
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
225
229
  function normalizeWindowsPath(input = "") {
226
- if (!input || !input.includes("\\")) {
230
+ if (!input) {
227
231
  return input;
228
232
  }
229
- return input.replace(/\\/g, "/");
233
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
230
234
  }
231
235
  const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
236
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
232
237
  function cwd() {
233
- if (typeof process !== "undefined") {
238
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
234
239
  return process.cwd().replace(/\\/g, "/");
235
240
  }
236
241
  return "/";
@@ -318,8 +323,11 @@ const isAbsolute = function(p) {
318
323
  return _IS_ABSOLUTE_RE.test(p);
319
324
  };
320
325
  const relative = function(from, to) {
321
- const _from = resolve(from).split("/");
322
- const _to = resolve(to).split("/");
326
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
327
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
328
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
329
+ return _to.join("/");
330
+ }
323
331
  const _fromCopy = [..._from];
324
332
  for (const segment of _fromCopy) {
325
333
  if (_to[0] !== segment) {
@@ -456,20 +464,25 @@ class StateManager {
456
464
  }).length;
457
465
  }
458
466
  cancelFiles(files, root, projectName) {
459
- this.collectFiles(files.map((filepath) => ({
460
- filepath,
461
- name: relative(root, filepath),
462
- id: filepath,
463
- mode: "skip",
464
- type: "suite",
465
- result: {
466
- state: "skip"
467
- },
468
- meta: {},
469
- // Cancelled files have not yet collected tests
470
- tasks: [],
471
- projectName
472
- })));
467
+ this.collectFiles(files.map((filepath) => {
468
+ const file = {
469
+ filepath,
470
+ name: relative(root, filepath),
471
+ id: filepath,
472
+ mode: "skip",
473
+ type: "suite",
474
+ result: {
475
+ state: "skip"
476
+ },
477
+ meta: {},
478
+ // Cancelled files have not yet collected tests
479
+ tasks: [],
480
+ projectName,
481
+ file: null
482
+ };
483
+ file.file = file;
484
+ return file;
485
+ }));
473
486
  }
474
487
  }
475
488
  function createClient(url, options = {}) {
@@ -595,7 +608,7 @@ const seen = {};
595
608
  const __vitePreload = function preload(baseModule, deps, importerUrl) {
596
609
  let promise = Promise.resolve();
597
610
  if (deps && deps.length > 0) {
598
- const links = document.getElementsByTagName("link");
611
+ document.getElementsByTagName("link");
599
612
  const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
600
613
  const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
601
614
  promise = Promise.all(deps.map((dep) => {
@@ -605,15 +618,7 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
605
618
  seen[dep] = true;
606
619
  const isCss = dep.endsWith(".css");
607
620
  const cssSelector = isCss ? '[rel="stylesheet"]' : "";
608
- const isBaseRelative = !!importerUrl;
609
- if (isBaseRelative) {
610
- for (let i = links.length - 1; i >= 0; i--) {
611
- const link2 = links[i];
612
- if (link2.href === dep && (!isCss || link2.rel === "stylesheet")) {
613
- return;
614
- }
615
- }
616
- } else if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
621
+ if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
617
622
  return;
618
623
  }
619
624
  const link = document.createElement("link");
@@ -10,7 +10,7 @@ var __publicField = (obj, key, value) => {
10
10
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
11
  return value;
12
12
  };
13
- import { i as importId, d as rpc$1, g as getConfig, _ as __vitePreload, b as channel, a as getBrowserState, c as client, l as loadSafeRpc, o as onCancel } from "./rpc-slP7oy1q.js";
13
+ import { i as importId, d as rpc$1, g as getConfig, _ as __vitePreload, b as channel, a as getBrowserState, c as client, l as loadSafeRpc, o as onCancel } from "./rpc-By4jD8av.js";
14
14
  function showPopupWarning(name, value, defaultValue) {
15
15
  return (...params) => {
16
16
  const formatedParams = params.map((p) => JSON.stringify(p)).join(", ");
@@ -23,8 +23,8 @@
23
23
  </style>
24
24
  <script>{__VITEST_INJECTOR__}</script>
25
25
  {__VITEST_SCRIPTS__}
26
- <script type="module" crossorigin src="/__vitest_browser__/main-v2hiOVax.js"></script>
27
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/rpc-slP7oy1q.js">
26
+ <script type="module" crossorigin src="/__vitest_browser__/main-DmAU-Uff.js"></script>
27
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/rpc-By4jD8av.js">
28
28
  </head>
29
29
  <body>
30
30
  <iframe id="vitest-ui" src=""></iframe>
@@ -17,8 +17,8 @@
17
17
  </style>
18
18
  <script>{__VITEST_INJECTOR__}</script>
19
19
  {__VITEST_SCRIPTS__}
20
- <script type="module" crossorigin src="/__vitest_browser__/tester-RmfypyZ0.js"></script>
21
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/rpc-slP7oy1q.js">
20
+ <script type="module" crossorigin src="/__vitest_browser__/tester-CrKhlp5g.js"></script>
21
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/rpc-By4jD8av.js">
22
22
  </head>
23
23
  <body>
24
24
  {__VITEST_APPEND__}
package/dist/index.js CHANGED
@@ -6,11 +6,12 @@ import { slash } from '@vitest/utils';
6
6
  import MagicString from 'magic-string';
7
7
  import { esmWalker } from '@vitest/utils/ast';
8
8
 
9
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
9
10
  function normalizeWindowsPath(input = "") {
10
- if (!input || !input.includes("\\")) {
11
+ if (!input) {
11
12
  return input;
12
13
  }
13
- return input.replace(/\\/g, "/");
14
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
14
15
  }
15
16
 
16
17
  const _UNC_REGEX = /^[/\\]{2}/;
@@ -65,7 +66,7 @@ const join = function(...arguments_) {
65
66
  return normalize(joined.replace(/\/\/+/g, "/"));
66
67
  };
67
68
  function cwd() {
68
- if (typeof process !== "undefined") {
69
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
69
70
  return process.cwd().replace(/\\/g, "/");
70
71
  }
71
72
  return "/";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "2.0.0-beta.2",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -43,7 +43,7 @@
43
43
  "peerDependencies": {
44
44
  "playwright": "*",
45
45
  "webdriverio": "*",
46
- "vitest": "1.6.0"
46
+ "vitest": "2.0.0-beta.2"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "playwright": {
@@ -57,22 +57,22 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "magic-string": "^0.30.5",
60
+ "magic-string": "^0.30.10",
61
61
  "sirv": "^2.0.4",
62
- "@vitest/utils": "1.6.0"
62
+ "@vitest/utils": "2.0.0-beta.2"
63
63
  },
64
64
  "devDependencies": {
65
- "@types/ws": "^8.5.9",
66
- "@wdio/protocols": "^8.29.7",
65
+ "@types/ws": "^8.5.10",
66
+ "@wdio/protocols": "^8.32.0",
67
67
  "periscopic": "^4.0.2",
68
- "playwright": "^1.41.0",
69
- "playwright-core": "^1.41.0",
68
+ "playwright": "^1.44.0",
69
+ "playwright-core": "^1.44.0",
70
70
  "safaridriver": "^0.1.2",
71
- "webdriverio": "^8.32.2",
72
- "@vitest/runner": "1.6.0",
73
- "@vitest/ui": "1.6.0",
74
- "@vitest/ws-client": "1.6.0",
75
- "vitest": "1.6.0"
71
+ "webdriverio": "^8.36.1",
72
+ "@vitest/ui": "2.0.0-beta.2",
73
+ "@vitest/ws-client": "2.0.0-beta.2",
74
+ "@vitest/runner": "2.0.0-beta.2",
75
+ "vitest": "2.0.0-beta.2"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "rimraf dist && pnpm build:node && pnpm build:client",