@allwright.dev/vitest 0.1.18 → 0.1.20
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.
- package/README.md +4 -4
- package/dist/expectations.js +7 -6
- package/dist/index.js +30 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ test("opens an Android app", async ({ androidApp }) => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test("opens an iOS app", async ({ iosApp }) => {
|
|
41
|
-
await iosApp.
|
|
41
|
+
await iosApp.getByRole("button", { name: "Login", exact: true }).click();
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -133,9 +133,9 @@ the test. The test remains platform-client code only:
|
|
|
133
133
|
import { expect, test } from "@allwright.dev/vitest";
|
|
134
134
|
|
|
135
135
|
test("logs in", async ({ iosApp }) => {
|
|
136
|
-
await iosApp.
|
|
137
|
-
await iosApp.
|
|
138
|
-
await expect(iosApp.
|
|
136
|
+
await iosApp.getByRole("button", { name: "Login", exact: true }).click();
|
|
137
|
+
await iosApp.getByLabel("Email", { exact: true }).fill("user@example.com");
|
|
138
|
+
await expect(iosApp.getByText("Welcome back", { exact: true })).toBeVisible();
|
|
139
139
|
});
|
|
140
140
|
```
|
|
141
141
|
|
package/dist/expectations.js
CHANGED
|
@@ -46,14 +46,15 @@ function expectedText(expected) {
|
|
|
46
46
|
}
|
|
47
47
|
async function isVisible(locator, command) {
|
|
48
48
|
if ("filter" in locator) {
|
|
49
|
-
return (await locator.filter({ visible: true }).count(command))
|
|
49
|
+
return (await locator.filter({ visible: true }).count(command)) > 0;
|
|
50
50
|
}
|
|
51
51
|
// Android has no visibility-filter query. An absent node is not visible; only
|
|
52
52
|
// its explicit native visibility failure is a negative observation.
|
|
53
|
-
if ((await locator.count(command))
|
|
53
|
+
if ((await locator.count(command)) === 0)
|
|
54
54
|
return false;
|
|
55
55
|
try {
|
|
56
|
-
|
|
56
|
+
await locator.waitFor({ ...command, visible: true });
|
|
57
|
+
return true;
|
|
57
58
|
}
|
|
58
59
|
catch (error) {
|
|
59
60
|
if (error instanceof Error && error.message.startsWith("selector found but not visible: "))
|
|
@@ -67,7 +68,7 @@ export function createLocatorExpect(locator, defaults, negated = false) {
|
|
|
67
68
|
get not() { return callableMatchers(createLocatorExpect(locator, defaults, !negated)); },
|
|
68
69
|
async toHaveText(expected, options = {}) {
|
|
69
70
|
await retryExpectation(async (command) => {
|
|
70
|
-
const
|
|
71
|
+
const text = await locator.textContent(command);
|
|
71
72
|
if (expected instanceof RegExp)
|
|
72
73
|
assertion(text).toMatch(new RegExp(expected.source, expected.flags));
|
|
73
74
|
else
|
|
@@ -76,7 +77,7 @@ export function createLocatorExpect(locator, defaults, negated = false) {
|
|
|
76
77
|
},
|
|
77
78
|
async toContainText(expected, options = {}) {
|
|
78
79
|
await retryExpectation(async (command) => {
|
|
79
|
-
const
|
|
80
|
+
const text = await locator.textContent(command);
|
|
80
81
|
if (expected instanceof RegExp)
|
|
81
82
|
assertion(text).toMatch(new RegExp(expected.source, expected.flags));
|
|
82
83
|
else
|
|
@@ -85,7 +86,7 @@ export function createLocatorExpect(locator, defaults, negated = false) {
|
|
|
85
86
|
},
|
|
86
87
|
async toHaveCount(expected, options = {}) {
|
|
87
88
|
await retryExpectation(async (command) => {
|
|
88
|
-
assertion(
|
|
89
|
+
assertion(await locator.count(command)).toBe(expected);
|
|
89
90
|
}, options, defaults());
|
|
90
91
|
},
|
|
91
92
|
async toBeVisible(options = {}) {
|
package/dist/index.js
CHANGED
|
@@ -340,9 +340,27 @@ function createLazyMobileApp(appResource) {
|
|
|
340
340
|
locator(selector) {
|
|
341
341
|
return createLazyMobileLocator(appResource, async () => selector);
|
|
342
342
|
},
|
|
343
|
+
getByRole(role, options) {
|
|
344
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).getByRole(role, options).selector);
|
|
345
|
+
},
|
|
346
|
+
getByText(text, options) {
|
|
347
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).getByText(text, options).selector);
|
|
348
|
+
},
|
|
349
|
+
getByLabel(text, options) {
|
|
350
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).getByLabel(text, options).selector);
|
|
351
|
+
},
|
|
352
|
+
getByTestId(text) {
|
|
353
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).getByTestId(text).selector);
|
|
354
|
+
},
|
|
343
355
|
async registerHook(type) {
|
|
344
356
|
return (await appResource.get()).registerHook(type);
|
|
345
357
|
},
|
|
358
|
+
async goto(url, options) {
|
|
359
|
+
return (await appResource.get()).goto(url, options);
|
|
360
|
+
},
|
|
361
|
+
async navigate(url, options) {
|
|
362
|
+
return (await appResource.get()).navigate(url, options);
|
|
363
|
+
},
|
|
346
364
|
async click(selector, options) {
|
|
347
365
|
return (await appResource.get()).click(selector, options);
|
|
348
366
|
},
|
|
@@ -411,6 +429,18 @@ function createLazyMobileLocator(appResource, selectorFactory) {
|
|
|
411
429
|
locator(selector) {
|
|
412
430
|
return createLazyMobileLocator(appResource, async () => (await appResource.get()).locator(await selectorFactory()).locator(selector).selector);
|
|
413
431
|
},
|
|
432
|
+
getByRole(role, options) {
|
|
433
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).locator(await selectorFactory()).getByRole(role, options).selector);
|
|
434
|
+
},
|
|
435
|
+
getByText(text, options) {
|
|
436
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).locator(await selectorFactory()).getByText(text, options).selector);
|
|
437
|
+
},
|
|
438
|
+
getByLabel(text, options) {
|
|
439
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).locator(await selectorFactory()).getByLabel(text, options).selector);
|
|
440
|
+
},
|
|
441
|
+
getByTestId(text) {
|
|
442
|
+
return createLazyMobileLocator(appResource, async () => (await appResource.get()).locator(await selectorFactory()).getByTestId(text).selector);
|
|
443
|
+
},
|
|
414
444
|
};
|
|
415
445
|
return lazyLocator;
|
|
416
446
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allwright.dev/vitest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Vitest fixtures for the allwright TypeScript client.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"prepublishOnly": "bun run build"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@allwright.dev/core": "0.1.
|
|
50
|
+
"@allwright.dev/core": "0.1.20"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typescript": "^5.9.2",
|