@enekesabel/playwright-lite 0.2.0 → 0.2.1
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 +2 -2
- package/dist/index.mjs +24 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ await page.getByRole("button", { name: "Save" }).click();
|
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
38
|
-
playwright-lite is
|
|
38
|
+
playwright-lite is pre-1.0; APIs may change.
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
npm add @enekesabel/playwright-lite
|
|
41
|
+
npm add @enekesabel/playwright-lite
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Requires Node.js 20 or newer.
|
package/dist/index.mjs
CHANGED
|
@@ -16006,7 +16006,7 @@ var PageImpl = class PageImpl {
|
|
|
16006
16006
|
const isArray = expression === "to.have.count" || expression.endsWith(".array");
|
|
16007
16007
|
const elements = this.resolveAll(selector);
|
|
16008
16008
|
if (!elements.length) return missingExpectationAttempt(expression, expectOptions);
|
|
16009
|
-
if (!isArray && elements.length > 1) throw
|
|
16009
|
+
if (!isArray && elements.length > 1) throw presentOriginalXPath(this.injected.strictModeViolationError(this.injected.parseSelector(selector), elements), selector);
|
|
16010
16010
|
const injectedOptions = Object.fromEntries(Object.entries(options).filter(([key]) => key !== "timeout" && key !== "signal"));
|
|
16011
16011
|
if (expression === "to.match.aria" && typeof injectedOptions.expectedValue === "string") injectedOptions.expectedValue = parseAriaExpectation(injectedOptions.expectedValue);
|
|
16012
16012
|
const result = await this.injected.expect(elements[0], {
|
|
@@ -16364,15 +16364,16 @@ var PageImpl = class PageImpl {
|
|
|
16364
16364
|
*/
|
|
16365
16365
|
async goto(url, options = {}) {
|
|
16366
16366
|
for (const [key, value] of Object.entries(options)) if (!["timeout", "waitUntil"].includes(key) && value !== void 0) throw new Error(`Unsupported Playwright option: goto.${key}`);
|
|
16367
|
-
const waitUntil = options.waitUntil
|
|
16368
|
-
if (
|
|
16369
|
-
"commit",
|
|
16370
|
-
"domcontentloaded",
|
|
16371
|
-
"load"
|
|
16372
|
-
].includes(waitUntil)) throw new Error(`Unsupported waitUntil value: ${waitUntil}`);
|
|
16367
|
+
const waitUntil = verifyLoadState("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
16368
|
+
if (waitUntil === "networkidle") throw new Error(`Unsupported waitUntil value: ${waitUntil}`);
|
|
16373
16369
|
const timeout = this.resolveTimeout(options.timeout, DEFAULT_NAVIGATION_TIMEOUT, true);
|
|
16374
16370
|
if (typeof url !== "string") throw new Error("goto URL must be a string");
|
|
16375
|
-
|
|
16371
|
+
let target;
|
|
16372
|
+
try {
|
|
16373
|
+
target = new URL(url, this.document.baseURI);
|
|
16374
|
+
} catch {
|
|
16375
|
+
throw new Error("page.goto: Cannot navigate to invalid URL");
|
|
16376
|
+
}
|
|
16376
16377
|
if (![
|
|
16377
16378
|
"http:",
|
|
16378
16379
|
"https:",
|
|
@@ -17661,6 +17662,21 @@ function assertElementHandleStateOptions(state, options) {
|
|
|
17661
17662
|
for (const key of Object.keys(options)) if (key !== "timeout") throw new Error(`Unsupported waitForElementState option: ${key}`);
|
|
17662
17663
|
if (options.timeout !== void 0) validateTimeout(options.timeout, "waitForElementState timeout");
|
|
17663
17664
|
}
|
|
17665
|
+
/**
|
|
17666
|
+
* Pinned 26a9e47 client/frame.ts `verifyLoadState`: accepts the four lifecycle
|
|
17667
|
+
* events, keeps the `networkidle0` alias, and rejects anything else with the
|
|
17668
|
+
* client's wording before the navigation is requested.
|
|
17669
|
+
*/
|
|
17670
|
+
function verifyLoadState(name, waitUntil) {
|
|
17671
|
+
if (waitUntil === "networkidle0") waitUntil = "networkidle";
|
|
17672
|
+
if (![
|
|
17673
|
+
"load",
|
|
17674
|
+
"domcontentloaded",
|
|
17675
|
+
"networkidle",
|
|
17676
|
+
"commit"
|
|
17677
|
+
].includes(waitUntil)) throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
|
|
17678
|
+
return waitUntil;
|
|
17679
|
+
}
|
|
17664
17680
|
function isRetryableQueryError(error) {
|
|
17665
17681
|
const message = asError(error).message;
|
|
17666
17682
|
return message.startsWith("No elements found for locator") || message === "Element is not connected";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enekesabel/playwright-lite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Playwright-compatible Page and Locator operations in the current browser document",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ábel Énekes",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pnpm generate:injected && tsdown",
|
|
36
36
|
"lint": "eslint src tests/contract --max-warnings 0",
|
|
37
|
-
"test": "vitest run && node --test scripts/upstream-baseline.test.mjs scripts/generate-readme.test.mjs scripts/release.test.mjs scripts/release-bootstrap.test.mjs",
|
|
37
|
+
"test": "vitest run && node --test scripts/upstream-baseline.test.mjs scripts/upstream-specs.test.mjs scripts/generate-readme.test.mjs scripts/release.test.mjs scripts/release-bootstrap.test.mjs",
|
|
38
38
|
"test:guards": "pnpm exec playwright test tests/upstream/_adapter-guard.spec.ts tests/upstream/_page-test-fixture.spec.ts tests/upstream/_synchronization-guard.spec.ts tests/upstream/_browser-compat-guard.spec.ts",
|
|
39
39
|
"typecheck": "tsc --noEmit && tsc -p tsconfig.compatibility.json --noEmit",
|
|
40
40
|
"test:e2e": "pnpm run test:guards && node scripts/upstream-baseline.mjs check",
|