@vitest/browser 2.1.3 → 2.1.5

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.
@@ -0,0 +1,195 @@
1
+ (function polyfill() {
2
+ const relList = document.createElement("link").relList;
3
+ if (relList && relList.supports && relList.supports("modulepreload")) {
4
+ return;
5
+ }
6
+ for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
7
+ processPreload(link);
8
+ }
9
+ new MutationObserver((mutations) => {
10
+ for (const mutation of mutations) {
11
+ if (mutation.type !== "childList") {
12
+ continue;
13
+ }
14
+ for (const node of mutation.addedNodes) {
15
+ if (node.tagName === "LINK" && node.rel === "modulepreload")
16
+ processPreload(node);
17
+ }
18
+ }
19
+ }).observe(document, { childList: true, subtree: true });
20
+ function getFetchOpts(link) {
21
+ const fetchOpts = {};
22
+ if (link.integrity) fetchOpts.integrity = link.integrity;
23
+ if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
24
+ if (link.crossOrigin === "use-credentials")
25
+ fetchOpts.credentials = "include";
26
+ else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
27
+ else fetchOpts.credentials = "same-origin";
28
+ return fetchOpts;
29
+ }
30
+ function processPreload(link) {
31
+ if (link.ep)
32
+ return;
33
+ link.ep = true;
34
+ const fetchOpts = getFetchOpts(link);
35
+ fetch(link.href, fetchOpts);
36
+ }
37
+ })();
38
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
39
+ function normalizeWindowsPath(input = "") {
40
+ if (!input) {
41
+ return input;
42
+ }
43
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
44
+ }
45
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
46
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
47
+ function cwd() {
48
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
49
+ return process.cwd().replace(/\\/g, "/");
50
+ }
51
+ return "/";
52
+ }
53
+ const resolve = function(...arguments_) {
54
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
55
+ let resolvedPath = "";
56
+ let resolvedAbsolute = false;
57
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
58
+ const path = index >= 0 ? arguments_[index] : cwd();
59
+ if (!path || path.length === 0) {
60
+ continue;
61
+ }
62
+ resolvedPath = `${path}/${resolvedPath}`;
63
+ resolvedAbsolute = isAbsolute(path);
64
+ }
65
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
66
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
67
+ return `/${resolvedPath}`;
68
+ }
69
+ return resolvedPath.length > 0 ? resolvedPath : ".";
70
+ };
71
+ function normalizeString(path, allowAboveRoot) {
72
+ let res = "";
73
+ let lastSegmentLength = 0;
74
+ let lastSlash = -1;
75
+ let dots = 0;
76
+ let char = null;
77
+ for (let index = 0; index <= path.length; ++index) {
78
+ if (index < path.length) {
79
+ char = path[index];
80
+ } else if (char === "/") {
81
+ break;
82
+ } else {
83
+ char = "/";
84
+ }
85
+ if (char === "/") {
86
+ if (lastSlash === index - 1 || dots === 1) ;
87
+ else if (dots === 2) {
88
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
89
+ if (res.length > 2) {
90
+ const lastSlashIndex = res.lastIndexOf("/");
91
+ if (lastSlashIndex === -1) {
92
+ res = "";
93
+ lastSegmentLength = 0;
94
+ } else {
95
+ res = res.slice(0, lastSlashIndex);
96
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
97
+ }
98
+ lastSlash = index;
99
+ dots = 0;
100
+ continue;
101
+ } else if (res.length > 0) {
102
+ res = "";
103
+ lastSegmentLength = 0;
104
+ lastSlash = index;
105
+ dots = 0;
106
+ continue;
107
+ }
108
+ }
109
+ if (allowAboveRoot) {
110
+ res += res.length > 0 ? "/.." : "..";
111
+ lastSegmentLength = 2;
112
+ }
113
+ } else {
114
+ if (res.length > 0) {
115
+ res += `/${path.slice(lastSlash + 1, index)}`;
116
+ } else {
117
+ res = path.slice(lastSlash + 1, index);
118
+ }
119
+ lastSegmentLength = index - lastSlash - 1;
120
+ }
121
+ lastSlash = index;
122
+ dots = 0;
123
+ } else if (char === "." && dots !== -1) {
124
+ ++dots;
125
+ } else {
126
+ dots = -1;
127
+ }
128
+ }
129
+ return res;
130
+ }
131
+ const isAbsolute = function(p) {
132
+ return _IS_ABSOLUTE_RE.test(p);
133
+ };
134
+ const relative = function(from, to) {
135
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
136
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
137
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
138
+ return _to.join("/");
139
+ }
140
+ const _fromCopy = [..._from];
141
+ for (const segment of _fromCopy) {
142
+ if (_to[0] !== segment) {
143
+ break;
144
+ }
145
+ _from.shift();
146
+ _to.shift();
147
+ }
148
+ return [..._from.map(() => ".."), ..._to].join("/");
149
+ };
150
+ async function importId(id) {
151
+ const name = `/@id/${id}`.replace(/\\/g, "/");
152
+ return (/* @__PURE__ */ getBrowserState()).wrapModule(() => import(
153
+ /* @vite-ignore */
154
+ name
155
+ ));
156
+ }
157
+ async function importFs(id) {
158
+ const name = `/@fs/${id}`.replace(/\\/g, "/");
159
+ return (/* @__PURE__ */ getBrowserState()).wrapModule(() => import(
160
+ /* @vite-ignore */
161
+ name
162
+ ));
163
+ }
164
+ const executor = {
165
+ isBrowser: true,
166
+ executeId: (id) => {
167
+ if (id[0] === "/" || id[1] === ":") {
168
+ return importFs(id);
169
+ }
170
+ return importId(id);
171
+ }
172
+ };
173
+ function getConfig() {
174
+ return (/* @__PURE__ */ getBrowserState()).config;
175
+ }
176
+ // @__NO_SIDE_EFFECTS__
177
+ function getBrowserState() {
178
+ return window.__vitest_browser_runner__;
179
+ }
180
+ // @__NO_SIDE_EFFECTS__
181
+ function getWorkerState() {
182
+ const state = window.__vitest_worker__;
183
+ if (!state) {
184
+ throw new Error("Worker state is not found. This is an issue with Vitest. Please, open an issue.");
185
+ }
186
+ return state;
187
+ }
188
+ export {
189
+ getConfig as a,
190
+ resolve as b,
191
+ getWorkerState as c,
192
+ executor as e,
193
+ getBrowserState as g,
194
+ relative as r
195
+ };
@@ -56,7 +56,9 @@ async function reportUnexpectedError(
56
56
  error,
57
57
  ) {
58
58
  const processedError = serializeError(error)
59
- await client.rpc.onUnhandledError(processedError, type)
59
+ await client.waitForConnection().then(() => {
60
+ return client.rpc.onUnhandledError(processedError, type)
61
+ }).catch(console.error)
60
62
  const state = __vitest_browser_runner__
61
63
 
62
64
  if (state.type === 'orchestrator') {
@@ -1,50 +1,52 @@
1
- const moduleCache = new Map();
2
-
3
- function wrapModule(module) {
4
- if (typeof module === "function") {
5
- const promise = new Promise((resolve, reject) => {
6
- if (typeof __vitest_mocker__ === "undefined")
7
- return module().then(resolve, reject);
8
- __vitest_mocker__.prepare().finally(() => {
9
- module().then(resolve, reject);
1
+ (() => {
2
+ const moduleCache = new Map();
3
+
4
+ function wrapModule(module) {
5
+ if (typeof module === "function") {
6
+ const promise = new Promise((resolve, reject) => {
7
+ if (typeof __vitest_mocker__ === "undefined")
8
+ return module().then(resolve, reject);
9
+ __vitest_mocker__.prepare().finally(() => {
10
+ module().then(resolve, reject);
11
+ });
10
12
  });
11
- });
12
- moduleCache.set(promise, { promise, evaluated: false });
13
- return promise.finally(() => moduleCache.delete(promise));
13
+ moduleCache.set(promise, { promise, evaluated: false });
14
+ return promise.finally(() => moduleCache.delete(promise));
15
+ }
16
+ return module;
14
17
  }
15
- return module;
16
- }
17
-
18
- window.__vitest_browser_runner__ = {
19
- wrapModule,
20
- wrapDynamicImport: wrapModule,
21
- moduleCache,
22
- config: { __VITEST_CONFIG__ },
23
- viteConfig: { __VITEST_VITE_CONFIG__ },
24
- files: { __VITEST_FILES__ },
25
- type: { __VITEST_TYPE__ },
26
- contextId: { __VITEST_CONTEXT_ID__ },
27
- testerId: { __VITEST_TESTER_ID__ },
28
- provider: { __VITEST_PROVIDER__ },
29
- providedContext: { __VITEST_PROVIDED_CONTEXT__ },
30
- };
31
-
32
- const config = __vitest_browser_runner__.config;
33
-
34
- if (config.testNamePattern)
35
- config.testNamePattern = parseRegexp(config.testNamePattern);
36
-
37
- function parseRegexp(input) {
38
- // Parse input
39
- const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
40
-
41
- // match nothing
42
- if (!m) return /$^/;
43
-
44
- // Invalid flags
45
- if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]))
46
- return RegExp(input);
47
-
48
- // Create the regular expression
49
- return new RegExp(m[2], m[3]);
50
- }
18
+
19
+ window.__vitest_browser_runner__ = {
20
+ wrapModule,
21
+ wrapDynamicImport: wrapModule,
22
+ moduleCache,
23
+ config: { __VITEST_CONFIG__ },
24
+ viteConfig: { __VITEST_VITE_CONFIG__ },
25
+ files: { __VITEST_FILES__ },
26
+ type: { __VITEST_TYPE__ },
27
+ contextId: { __VITEST_CONTEXT_ID__ },
28
+ testerId: { __VITEST_TESTER_ID__ },
29
+ provider: { __VITEST_PROVIDER__ },
30
+ providedContext: { __VITEST_PROVIDED_CONTEXT__ },
31
+ };
32
+
33
+ const config = __vitest_browser_runner__.config;
34
+
35
+ if (config.testNamePattern)
36
+ config.testNamePattern = parseRegexp(config.testNamePattern);
37
+
38
+ function parseRegexp(input) {
39
+ // Parse input
40
+ const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
41
+
42
+ // match nothing
43
+ if (!m) return /$^/;
44
+
45
+ // Invalid flags
46
+ if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]))
47
+ return RegExp(input);
48
+
49
+ // Create the regular expression
50
+ return new RegExp(m[2], m[3]);
51
+ }
52
+ })();
@@ -26,8 +26,8 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-BCPid0xo.js"></script>
30
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-D-WYp1PK.js">
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-DnP17K36.js"></script>
30
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
31
31
  </head>
32
32
  <body>
33
33
  <div id="vitest-tester"></div>
@@ -4,26 +4,10 @@
4
4
  <meta charset="UTF-8" />
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
- <title>{__VITEST_TITLE__}</title>
8
- <style>
9
- html {
10
- padding: 0;
11
- margin: 0;
12
- }
13
- body {
14
- padding: 0;
15
- margin: 0;
16
- min-height: 100vh;
17
- }
18
- </style>
19
- {__VITEST_INJECTOR__}
20
- <script>{__VITEST_STATE__}</script>
21
- {__VITEST_INTERNAL_SCRIPTS__}
22
- {__VITEST_SCRIPTS__}
23
- <script type="module" crossorigin src="/__vitest_browser__/tester-DZCtFstH.js"></script>
24
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/preload-helper-D-WYp1PK.js">
7
+ <title>Vitest Browser Tester</title>
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-BaiNqOPw.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
25
10
  </head>
26
11
  <body>
27
- {__VITEST_APPEND__}
28
12
  </body>
29
13
  </html>
package/dist/client.js CHANGED
@@ -9,18 +9,24 @@ function createBirpc(functions, options) {
9
9
  const {
10
10
  post,
11
11
  on,
12
+ off = () => {
13
+ },
12
14
  eventNames = [],
13
15
  serialize = defaultSerialize,
14
16
  deserialize = defaultDeserialize,
15
17
  resolver,
18
+ bind = "rpc",
16
19
  timeout = DEFAULT_TIMEOUT
17
20
  } = options;
18
21
  const rpcPromiseMap = /* @__PURE__ */ new Map();
19
22
  let _promise;
23
+ let closed = false;
20
24
  const rpc = new Proxy({}, {
21
25
  get(_, method) {
22
26
  if (method === "$functions")
23
27
  return functions;
28
+ if (method === "$close")
29
+ return close;
24
30
  if (method === "then" && !eventNames.includes("then") && !("then" in functions))
25
31
  return void 0;
26
32
  const sendEvent = (...args) => {
@@ -31,7 +37,15 @@ function createBirpc(functions, options) {
31
37
  return sendEvent;
32
38
  }
33
39
  const sendCall = async (...args) => {
34
- await _promise;
40
+ if (closed)
41
+ throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
42
+ if (_promise) {
43
+ try {
44
+ await _promise;
45
+ } finally {
46
+ _promise = void 0;
47
+ }
48
+ }
35
49
  return new Promise((resolve, reject) => {
36
50
  const id = nanoid();
37
51
  let timeoutId;
@@ -48,7 +62,7 @@ function createBirpc(functions, options) {
48
62
  if (typeof timeoutId === "object")
49
63
  timeoutId = timeoutId.unref?.();
50
64
  }
51
- rpcPromiseMap.set(id, { resolve, reject, timeoutId });
65
+ rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
52
66
  post(serialize({ m: method, a: args, i: id, t: "q" }));
53
67
  });
54
68
  };
@@ -56,7 +70,15 @@ function createBirpc(functions, options) {
56
70
  return sendCall;
57
71
  }
58
72
  });
59
- _promise = on(async (data, ...extra) => {
73
+ function close() {
74
+ closed = true;
75
+ rpcPromiseMap.forEach(({ reject, method }) => {
76
+ reject(new Error(`[birpc] rpc is closed, cannot call "${method}"`));
77
+ });
78
+ rpcPromiseMap.clear();
79
+ off(onMessage);
80
+ }
81
+ async function onMessage(data, ...extra) {
60
82
  const msg = deserialize(data);
61
83
  if (msg.t === "q") {
62
84
  const { m: method, a: args } = msg;
@@ -66,7 +88,7 @@ function createBirpc(functions, options) {
66
88
  error = new Error(`[birpc] function "${method}" not found`);
67
89
  } else {
68
90
  try {
69
- result = await fn.apply(rpc, args);
91
+ result = await fn.apply(bind === "rpc" ? rpc : functions, args);
70
92
  } catch (e) {
71
93
  error = e;
72
94
  }
@@ -88,7 +110,8 @@ function createBirpc(functions, options) {
88
110
  }
89
111
  rpcPromiseMap.delete(ack);
90
112
  }
91
- });
113
+ }
114
+ _promise = on(onMessage);
92
115
  return rpc;
93
116
  }
94
117
  const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
package/dist/context.js CHANGED
@@ -1,3 +1,35 @@
1
+ function ensureAwaited(promise) {
2
+ const test = (/* @__PURE__ */ getWorkerState()).current;
3
+ if (!test || test.type !== "test") {
4
+ return promise();
5
+ }
6
+ let awaited = false;
7
+ const sourceError = new Error("STACK_TRACE_ERROR");
8
+ test.onFinished ??= [];
9
+ test.onFinished.push(() => {
10
+ if (!awaited) {
11
+ const error = new Error(
12
+ `The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`
13
+ );
14
+ error.stack = sourceError.stack?.replace(sourceError.message, error.message);
15
+ throw error;
16
+ }
17
+ });
18
+ let promiseResult;
19
+ return {
20
+ then(onFulfilled, onRejected) {
21
+ awaited = true;
22
+ return (promiseResult ||= promise()).then(onFulfilled, onRejected);
23
+ },
24
+ catch(onRejected) {
25
+ return (promiseResult ||= promise()).catch(onRejected);
26
+ },
27
+ finally(onFinally) {
28
+ return (promiseResult ||= promise()).finally(onFinally);
29
+ },
30
+ [Symbol.toStringTag]: "Promise"
31
+ };
32
+ }
1
33
  // @__NO_SIDE_EFFECTS__
2
34
  function getBrowserState() {
3
35
  return window.__vitest_browser_runner__;
@@ -90,22 +122,33 @@ const channel = new BroadcastChannel(`vitest:${contextId}`);
90
122
  function triggerCommand(command, ...args) {
91
123
  return rpc().triggerCommand(contextId, command, filepath(), args);
92
124
  }
93
- function createUserEvent(__tl_user_event__) {
125
+ function createUserEvent(__tl_user_event_base__, options) {
126
+ let __tl_user_event__ = __tl_user_event_base__?.setup(options ?? {});
94
127
  const keyboard = {
95
128
  unreleased: []
96
129
  };
97
130
  return {
98
- setup(options) {
99
- return createUserEvent(__tl_user_event__?.setup(options));
131
+ setup(options2) {
132
+ return createUserEvent(__tl_user_event_base__, options2);
133
+ },
134
+ async cleanup() {
135
+ return ensureAwaited(async () => {
136
+ if (typeof __tl_user_event_base__ !== "undefined") {
137
+ __tl_user_event__ = __tl_user_event_base__?.setup(options ?? {});
138
+ return;
139
+ }
140
+ await triggerCommand("__vitest_cleanup", keyboard);
141
+ keyboard.unreleased = [];
142
+ });
100
143
  },
101
- click(element, options = {}) {
102
- return convertToLocator(element).click(processClickOptions(options));
144
+ click(element, options2 = {}) {
145
+ return convertToLocator(element).click(processClickOptions(options2));
103
146
  },
104
- dblClick(element, options = {}) {
105
- return convertToLocator(element).dblClick(processClickOptions(options));
147
+ dblClick(element, options2 = {}) {
148
+ return convertToLocator(element).dblClick(processClickOptions(options2));
106
149
  },
107
- tripleClick(element, options = {}) {
108
- return convertToLocator(element).tripleClick(processClickOptions(options));
150
+ tripleClick(element, options2 = {}) {
151
+ return convertToLocator(element).tripleClick(processClickOptions(options2));
109
152
  },
110
153
  selectOptions(element, value) {
111
154
  return convertToLocator(element).selectOptions(value);
@@ -113,58 +156,64 @@ function createUserEvent(__tl_user_event__) {
113
156
  clear(element) {
114
157
  return convertToLocator(element).clear();
115
158
  },
116
- hover(element, options = {}) {
117
- return convertToLocator(element).hover(processHoverOptions(options));
159
+ hover(element, options2 = {}) {
160
+ return convertToLocator(element).hover(processHoverOptions(options2));
118
161
  },
119
- unhover(element, options = {}) {
120
- return convertToLocator(element).unhover(options);
162
+ unhover(element, options2 = {}) {
163
+ return convertToLocator(element).unhover(options2);
121
164
  },
122
165
  upload(element, files) {
123
166
  return convertToLocator(element).upload(files);
124
167
  },
125
168
  // non userEvent events, but still useful
126
- fill(element, text, options) {
127
- return convertToLocator(element).fill(text, options);
169
+ fill(element, text, options2) {
170
+ return convertToLocator(element).fill(text, options2);
128
171
  },
129
- dragAndDrop(source, target, options = {}) {
172
+ dragAndDrop(source, target, options2 = {}) {
130
173
  const sourceLocator = convertToLocator(source);
131
174
  const targetLocator = convertToLocator(target);
132
- return sourceLocator.dropTo(targetLocator, processDragAndDropOptions(options));
175
+ return sourceLocator.dropTo(targetLocator, processDragAndDropOptions(options2));
133
176
  },
134
177
  // testing-library user-event
135
- async type(element, text, options = {}) {
136
- if (typeof __tl_user_event__ !== "undefined") {
137
- return __tl_user_event__.type(
138
- element instanceof Element ? element : element.element(),
178
+ async type(element, text, options2 = {}) {
179
+ return ensureAwaited(async () => {
180
+ if (typeof __tl_user_event__ !== "undefined") {
181
+ return __tl_user_event__.type(
182
+ element instanceof Element ? element : element.element(),
183
+ text,
184
+ options2
185
+ );
186
+ }
187
+ const selector = convertToSelector(element);
188
+ const { unreleased } = await triggerCommand(
189
+ "__vitest_type",
190
+ selector,
139
191
  text,
140
- options
192
+ { ...options2, unreleased: keyboard.unreleased }
141
193
  );
142
- }
143
- const selector = convertToSelector(element);
144
- const { unreleased } = await triggerCommand(
145
- "__vitest_type",
146
- selector,
147
- text,
148
- { ...options, unreleased: keyboard.unreleased }
149
- );
150
- keyboard.unreleased = unreleased;
194
+ keyboard.unreleased = unreleased;
195
+ });
151
196
  },
152
- tab(options = {}) {
153
- if (typeof __tl_user_event__ !== "undefined") {
154
- return __tl_user_event__.tab(options);
155
- }
156
- return triggerCommand("__vitest_tab", options);
197
+ tab(options2 = {}) {
198
+ return ensureAwaited(() => {
199
+ if (typeof __tl_user_event__ !== "undefined") {
200
+ return __tl_user_event__.tab(options2);
201
+ }
202
+ return triggerCommand("__vitest_tab", options2);
203
+ });
157
204
  },
158
205
  async keyboard(text) {
159
- if (typeof __tl_user_event__ !== "undefined") {
160
- return __tl_user_event__.keyboard(text);
161
- }
162
- const { unreleased } = await triggerCommand(
163
- "__vitest_keyboard",
164
- text,
165
- keyboard
166
- );
167
- keyboard.unreleased = unreleased;
206
+ return ensureAwaited(async () => {
207
+ if (typeof __tl_user_event__ !== "undefined") {
208
+ return __tl_user_event__.keyboard(text);
209
+ }
210
+ const { unreleased } = await triggerCommand(
211
+ "__vitest_keyboard",
212
+ text,
213
+ keyboard
214
+ );
215
+ keyboard.unreleased = unreleased;
216
+ });
168
217
  }
169
218
  };
170
219
  }
@@ -205,10 +254,10 @@ const page = {
205
254
  screenshotIds[repeatCount] ??= {};
206
255
  screenshotIds[repeatCount][taskName] = number + 1;
207
256
  const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
208
- return triggerCommand("__vitest_screenshot", name, {
257
+ return ensureAwaited(() => triggerCommand("__vitest_screenshot", name, {
209
258
  ...options,
210
259
  element: options.element ? convertToSelector(options.element) : void 0
211
- });
260
+ }));
212
261
  },
213
262
  getByRole() {
214
263
  throw new Error('Method "getByRole" is not implemented in the current provider.');