Skip to content

feat(playwright): @keploy/playwright joins a Playwright suite to keploy mock record and replay - #118

Merged
slayerjain merged 14 commits into
mainfrom
feat/playwright
Nov 1, 2026
Merged

slayerjain merged 14 commits into
mainfrom
feat/playwright

Conversation

@slayerjain

@slayerjain slayerjain commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fourteen commits on main a063214. New package in playwright/. The root package is unchanged, except that the root tsconfig.json now excludes playwright/. Commits 3 to 5 fix this PR's red CI and add the npm publish workflow (below). Commits 6 to 14 answer the reviews: a row for every settle rule and agent check (a rule no row can fail is removed), the limits and release rule written in the repo, a race in the rows' own harness fixed, what given needs named by its keploy release, and the switch keploy needs, KEPLOY_PROVEN=1, named where the package is used and in the claim's error.

What it is

A thin client of keploy's scope protocol v1. This is the wire that go-sdk's keploytest speaks: POST /agent/instance, /agent/scope/begin, /agent/scope/end and /agent/scope/given. Specs import test and expect from @keploy/playwright instead of @playwright/test. The package decides nothing. keploy's agent judges each test, and the package does what the agent answers. It is OSS (Apache-2.0, like this repo) because users install it, as they install go-sdk.

Behaviour

  • Needs keploy run with KEPLOY_PROVEN=1. keploy speaks scope protocol v1, this package's wire (the claim, begin, end and given), only under that switch, keploy's switch for its proven model; it is off by default. With it off, the agent has no POST /agent/instance route and answers the claim with a plain 404 (its begin and end answer an older, unversioned wire). The README's "Use" says so once and shows the commands as KEPLOY_PROVEN=1 keploy mock record -c "npx playwright test --workers=1 --retries=0" and KEPLOY_PROVEN=1 keploy mock replay -c ....

  • Inert when KEPLOY_MOCK_AGENT is unset or off. A value that is neither off nor an http URL fails every test and names the value. A process inside the claimer, whose KEPLOY_TEST_PID names an ancestor, stays inert.

  • Claim. A worker-scoped auto fixture claims the run before the worker's first hook or test. Its key is the Playwright project's name, or . when the project is unnamed. The fixture then exports KEPLOY_TEST_PID. A refused claim fails the worker's tests with keploy's message and remedy. A claim answered with a plain 404 (no keploy error code) fails them with a named error: keploy: this keploy agent answered 404 to POST /agent/instance, so this worker cannot claim keploy's run: keploy speaks @keploy/playwright's wire, scope protocol v1, only when it runs with KEPLOY_PROVEN=1 (KEPLOY_PROVEN=1 keploy mock record|replay -c "npx playwright test --workers=1 --retries=0"); a keploy run without KEPLOY_PROVEN=1, or one from before scope protocol v1, answers 404 there.

  • Begin. The test begins before its beforeEach hooks, with {name, file, project, canSkip: true}. The file is relative to KEPLOY_MOCK_PROJECT. The name is the describe titles and the test's title, joined with ›. On action: skip, Playwright's own skip skips the test with keploy's reason, and no end is sent.

  • Settle. Before the context fixture closes, the test waits until none of its pages' calls is in flight. Calls are counted by request events, with no time window.

    • A call the browser cancelled is not waited for: its page loaded another document, its frame was removed, its page closed, or the test closed its own context. The browser ends a removed frame's calls itself. It reports no end for the calls of a document loaded over, of a closed page, or of a closed context, so the package drops those itself.
    • A closing page drops only its own calls: a popup that closes (an OAuth or payment window) cancels nothing of its opener's, and nothing of a service worker's.
    • The test closing its own context drops every call in flight. It is the only rule that drops a service worker's call: that call has no frame, so no page's close drops it, and Chromium ends the worker with its context without reporting an end for the call. Without the rule, a test that closes its context while its service worker has a call open waits until its timeout (row below).
    • A route change inside the page cancels nothing, even right after an answered call, and neither does a navigation answered 204 or 205, or a download (an attachment, in any letter case). A navigation's own request stays in flight until its document's last byte, after the frame commits it.
    • A service worker's call has no frame (Playwright's request.frame() throws for it). It is counted like a page's call. No page change drops it; the context's close does.
    • A call that never ends fails the test at Playwright's timeout, with a step that names the call.
  • End. After the last teardown, the test ends with its own outcome. test.fail() counts the way Playwright counts it. On action: fail, the test fails with keploy's text.

  • given(name, value). Sends the value only while a test is open, with the caller's file:line relative to the project. Outside an open test it fails and sends nothing.

    • It needs keploy v3.6.192 or later. The route, POST /agent/scope/given, came with keploy#5016, released in keploy v3.6.192. With the enterprise keploy, that is an enterprise release on keploy v3.6.192 or later (enterprise main and v3.8.103 still pin v3.6.190). given runs only in a worker whose claim the agent took, so the switch is on there and only the version can be missing. On an older keploy, given fails the test with: keploy: this keploy agent answered 404 to POST /agent/scope/given, so it cannot take the given value <name>: given needs keploy v3.6.192 or later (keploy/keploy#5016), or an enterprise release on keploy v3.6.192 or later; an older keploy answers 404 there. A 404 that carries keploy's own refusal (an error code and message) is keploy's answer, not a missing route, and shows keploy's message and remedy.
    • Claim, begin, settle and end work with released keploy run with KEPLOY_PROVEN=1, so 0.1.0 is usable without given. The README states this as a limit.
  • Answers it cannot trust fail the test:

    • an agent it cannot reach;
    • a non-2xx answer, which shows keploy's message and remedy;
    • an unreadable answer, or one over 1 MiB;
    • an answer with no v, or with another version;
    • an unknown action.

    Nothing is retried, and there is no timeout.

Proof

  • test/unit.test.mjs: 17 rows covering the client, the join rule, the wire names and how keploy's reason is shown. Among them: a 307 from the agent is an error and is not followed; an end answered with a status other than ok is an error; a claim answered 404 with no refusal names the route, the switch and the command, one answered 404 with keploy's refusal shows that refusal, and a plain 500 keeps the generic text; a given answered 404 with no refusal names the route and the keploy version, and one answered 404 with keploy's refusal shows that refusal; a spec reached through a symbolic link is named by its real path.

  • test/release.test.mjs: 4 rows for the publish job's version check.

  • test/rows.test.mjs: 24 rows. They run real Playwright 1.62.1 against test/fixtures and a fake agent:

    • inert (unset and off);
    • the order of claim, begin, given and end, with each outcome and the re-claim by the new worker after a failed test;
    • a skip with its reason, where the body does not run;
    • a test judged red, showing keploy's reason once (the agent's reason already starts with keploy: );
    • a refused begin, a refused claim, and a malformed agent URL;
    • a given outside a test;
    • an unnamed Playwright project: the claim's key is . and the tests name no project;
    • seventeen settle rows with Chromium:
      • answered before the end;
      • never answered: times out, and names the call;
      • not waited for: cancelled by a new document, a removed cross-site frame, a closed page, the test closing its own context (a page's call, and a service worker's);
      • still waited for: a route change, a route change right after an answered call, another page of the test closing (for a page's call, and for a service worker's), a navigation answered 204, one answered 205, a download answered Attachment and one answered attachment, a document still loading after its frame commits (named by its own URL), and a service worker's call.
      • each row that asserts the server saw the cancelled call waits, before it cancels, until the page server has received it (/seen, answered on the server's own event). Before, a spec cancelled on the browser's request event, which comes before the call reaches the server; on a loaded box the cancel could win, and the row failed although the test passed for the right reason.
  • 45 of 45 rows pass on Node.js 20, 22 and 24 on a test box (CI proof below).

  • The one earlier unexplained failure of a "not waited for" row is explained, and commit 11 fixes it. In this branch's gate run at d025a19 (box load 7 to 9 on 16 CPUs), the row "the test closes its own context" failed: the test passed, but the page server never logged the call. The spec closed the context on the browser's request event, which comes before the call reaches the server, and the cancel won. The second review's removed-frame failure kept no detail; that row makes the same assertion after the same kind of cancel. Each of the five rows that assert the server saw the cancelled call now waits for the server's /seen before it cancels. The race is rare: 50 runs of those five rows at d025a19 and 50 at 4af8269, interleaved (20 idle, 30 beside 12 busy loops; box load up to 18.7 on 16 CPUs), failed none either way. The fix is decided by the server's own event, from the code, not by that count.

  • Mutants, each run against every row:

    • the first round's 26 are all killed;
    • the first review's 17: 16 compile, and 15 are killed, each by its row. The 16th removed settle's rule for a removed frame's calls, and it got past the removed-frame row with a same-site frame and with a cross-site one, because Chromium ends those calls itself. A rule no row can fail is surface with no proof, so commit 6 removes it; the row stays and proves the behaviour;
    • the second review's 7 are all killed: one (a frame left marked as loading after it commits) by the earlier navigation rows, 5 by the rows of commits 8 and 9 (a closing page dropping every page's calls; any answered call marking its frame as loading; given's 404 rule ignoring keploy's error code; a case-sensitive attachment check; a service worker's call throwing in the request handler), and the 7th, which removes the context's close rule, by commit 10's row: a service worker's call in flight when the test closes its own context. Chromium reports no end for that call and no page's close drops it, so without the rule the test waits until its timeout. The rule stays;
    • the third review's 3 are killed by commit 10's rows: the context's close rule removed, a closing page dropping a service worker's call too, and an attachment check that matches only Attachment. Limiting the context's close rule to calls with a frame is killed by the same row;
    • the fourth review's 13: 11 were killed by the rows already there. The 12th, removing settle's wake after a drop, got past every row, because every cancel in them came before settle waited. Commit 13's unit row drives settle with a fake browser context, no browser and no timer: a page's call in flight, settle waiting, another page's close (still waiting), then the call's own page closing wakes it; with a service worker's call in flight too, that page's close leaves settle waiting, and the test closing its context wakes it. It kills that mutant, and one that drops wake's own empty check. The 13th, a context close that drops only calls without a frame, is equivalent: the context closes its pages first, and each page's close drops that page's calls.

    Each mutant removes or weakens one guard: settle, skip, fail, KEPLOY_TEST_PID, given's open check, outcome mapping, claim key, refused join, the navigation rules, the v check, a missing v, a non-object answer, begin status, end action, missing instance, the size bound, given's 404 rule and empty variable, the token header, off, the ancestor marker, the reason's prefix (always added, never added) and fallback, and settle's context-close, page, frame, attachment and service worker checks.

  • The root build fails without the new exclude: tsc compiles playwright/src and cannot find @playwright/test. With the exclude it passes.

CI

  • @keploy/playwright rows (.github/workflows/playwright-sdk.yml): on pull requests and main pushes that touch playwright/, Node.js 20, 22 and 24 each run npm ci, npx playwright install --with-deps chromium and npm test. The first run failed on Node 18 ("Playwright requires Node.js 20 or higher"), and the matrix's default fail-fast then cancelled the Node 22 leg, whose 24 rows had passed. Now engines.node is >=20 (the README says so), 18 is gone, 24 (the active LTS) is in, and fail-fast: false keeps each leg's result its own.

  • Check PR (.github/workflows/ci.yml, the repo's existing type check): it failed on every pull request before this one, because borales/actions-yarn@v2.1.0 runs an image with no yarn ("sh: yarn: not found"). The repo uses npm (package-lock.json, no yarn.lock), so the check now runs actions/setup-node@v4 (Node.js 22) with npm ci and npm run build. Open PR ci: build on Node 20 and publish releases from tags #117 makes the same change on Node 20; whichever lands second keeps one of them.

  • Publish (.github/workflows/playwright-publish.yml, new): pushing the tag playwright-vX.Y.Z runs the rows on the tagged commit (the rows workflow, called), then npm publish --access public --provenance from playwright/ with the repository secret NPM_TOKEN. Before anything is uploaded, the job refuses with a named error:

    • a tag that does not name package.json's version exactly, or a version that is not a release x.y.z (npm 10 would make a prerelease latest): scripts/release-version.mjs, with 4 rows in test/release.test.mjs;
    • an empty NPM_TOKEN;
    • an @keploy:registry other than https://registry.npmjs.org/, read as npm will use it, from every npmrc (setup-node pins it);
    • a token npm whoami cannot authenticate.

    npm itself refuses a version it already has. prepublishOnly builds dist/, so a publish from a fresh checkout carries it. On pull requests a dry-run job runs npm publish --dry-run with no token, and fails when the package would ship without dist/index.js, dist/index.d.ts, package.json or README.md.

CI proof at cd02d83 (a test box with 16 CPUs, each command in the node:<version>-bookworm image; load 8.3 at the start, 5.6 at the end, under 1 per CPU):

  • rows: 45 of 45 pass on Node.js 20.20.2, 22.23.4 and 24.22.2;
  • mutants of commit 14, on Node.js 22, each against the claim and given rows: the claim's 404 rule removed, matching any 404 (keploy's own refusal too), matching any plain answer (a 500 too), its text without the switch, and without the command; given's 404 rule removed, matching any 404, and its text naming the switch again. All 8 are killed by the claim row or the given row;
  • mutants at b390fc9 (a 24-CPU box, load 6.1 to 20.9), on Node.js 22, each against the 18 settle rows (or the given rows): the fourth review's 13 and one more (wake's empty check removed). 13 are killed; the one that passes, a context close that drops only calls without a frame, is equivalent (above);
  • earlier mutants: the 13 settle mutants of the third review's round (the third review's 3, the context's close rule limited to calls with a frame, and the second review's settle ones, with the page close removed, a failed request not counted and a 205 navigation not kept) were run at d025a19 against the 18 settle rows on Node.js 22, on a 16-CPU box at load 3 to 7: all 13 killed. Commits 11 and 13 change only the rows. Since f63d4f4, settle.ts changed only by comments, and agent.ts only in given's 404 message, the claim's 404 rule (commit 14, its mutants above) and comments, so the earlier mutants of the agent client and the fixture stand;
  • Check PR's commands (npm ci, npm run build at the root, Node.js 22): pass at f63d4f4; the root package has not changed since;
  • commitlint 17.8.1 with the repo's .commitlintrc.json (config-conventional, the Check PR's commit check) over this PR's fourteen commits: pass;
  • the publish job's guard steps, run from the workflow's own text at 8179863 (since then the workflow changed only in its header comment): an empty token, a mirror in the user npmrc, a mirror in a project .npmrc, no scope setting and a wrong tag are each refused; setup-node's npmrc, a set token and the right tag pass. The dry run from a tree with no dist/ carries all four files; with prepublishOnly removed it fails. Removing the token check or the scope check lets a refused case through. The 6 mutants of release-version.mjs (release check gone or unanchored, tag check gone or prefix-only, no exit code, always-main) all fail its rows;
  • actionlint 1.7.7 (with shellcheck), run locally, not on the box: 0 errors on every workflow.
  • Not provable off GitHub: fail-fast: false and the tag-triggered run itself. The first tag push is the proof of the publish.

Limits (all five in the README's "Limits of this version")

  • Settle covers the context and page fixtures. A context the test makes with browser.newContext() is the test's own to close.
  • Settle's rows run in Chromium only. Which calls the browser ends itself (a removed frame's) is proven there; Firefox and WebKit are not rowed.
  • Calls that beforeAll/afterAll hooks and worker fixtures make outside every test are answered from the worker's claim, with one slice per Playwright project.
  • The beforeAll/afterAll hooks of a describe group whose tests are all set aside still run. Each test is skipped at its own begin. Skipping the whole group before its hooks run needs a way to ask keploy for the set-aside tests first, which this version does not have.
  • given needs keploy v3.6.192 or later, or an enterprise release on keploy v3.6.192 or later (above).

Releasing (in the README's "Releasing" and the publish workflow's header)

Bump version in a pull request, then push playwright-vX.Y.Z as a plain git tag on that commit of main. Never create a GitHub release for it: a published release starts every workflow of this repository that runs on releases, such as #117's release.yml, which would try npm version playwright-v... and fail.

Merge order

This PR merges first. Then the tag playwright-v0.1.0 publishes 0.1.0, and enterprise-ui#2033 switches from its vendored tarball to "@keploy/playwright": "0.1.0" before it merges.

…oy mock record and replay

A new package in playwright/, @keploy/playwright: a thin client of keploy's
scope protocol v1, the same wire go-sdk's keploytest speaks. Specs import
test and expect from it instead of @playwright/test. It decides nothing:
keploy's agent judges, and the package does what the agent answers.

- Inert with KEPLOY_MOCK_AGENT unset or "off"; a value that is neither off
  nor an http URL fails every test, naming it. A process inside the claimer
  (KEPLOY_TEST_PID names an ancestor) stays inert.
- Claim: a worker-scoped auto fixture claims the run (POST /agent/instance)
  before the worker's first hook or test, keyed by the Playwright project's
  name ("." when unnamed), and exports KEPLOY_TEST_PID. A refused claim
  fails the worker's tests with keploy's message and remedy.
- Begin: a test-scoped auto fixture begins the test (POST
  /agent/scope/begin {name, file, project, canSkip}) before its beforeEach
  hooks. The file is relative to KEPLOY_MOCK_PROJECT; the name is the
  describe titles and the test's title joined with " › ". action skip skips
  the test through Playwright's skip with keploy's reason, and sends no end.
- Settle: the context fixture waits, before the context closes, until none
  of its pages' calls is in flight, counted by request events. A call the
  browser cancelled (its page loaded another document, its frame went, its
  page closed) is not waited for; a route change inside the page cancels
  nothing. A call that never ends fails the test at Playwright's timeout,
  with a step naming it.
- End: after the last teardown, POST /agent/scope/end with the test's own
  outcome (passed, failed, skipped; test.fail() counts as Playwright does).
  action fail fails the test with keploy's text.
- given(name, value): POST /agent/scope/given while a test is open, with
  the caller's file:line; outside an open test it fails and sends nothing.
  An agent without the route is told apart (use matching releases).
- Every answer the package cannot trust fails the test: unreachable, non-2xx
  (keploy's message and remedy), unreadable, over 1 MiB, no "v" or another
  version, an unknown action. No retry, no timeout.

The root tsconfig now excludes playwright/, which builds on its own: without
that, the root build compiles playwright/src and fails on @playwright/test.

Rows: test/unit.test.mjs (client, join rule, wire names) and
test/rows.test.mjs (real Playwright 1.62.1 runs of test/fixtures against a
fake agent: inert, claim/begin/given/end order and outcomes with the
re-claim after a failed test, skip with reason, judged red, refused begin,
refused claim, malformed agent URL, given outside a test, and five settle
rows with Chromium). Mutants: 23, all killed. CI:
.github/workflows/playwright-sdk.yml, Node 18 and 22.

Limits, stated in the README: settle covers the context and page fixtures,
not a context the test makes with browser.newContext(); calls beforeAll and
afterAll hooks make are answered from the worker's claim, one slice per
Playwright project.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…ves none

keploy's judging reason already starts with "keploy: ", and the end of a
test prefixed it again: a replay of enterprise-ui's smart-set-pagination
failed its two Stripe-beacon tests with "keploy: keploy: GET
/v3/.deploy_status_henson.json to js.stripe.com had no recorded answer".
A skip reason ("<class>/<reason>: <detail>") carries no prefix, so the
skip still adds it.

keployText now prefixes a reason only when it lacks "keploy: ", and
shows the same fallback texts go-sdk's keploytest shows when the agent
gives no reason. Rows: the judged-red row uses the agent's real reason
shape and refuses a doubled prefix; keployText's unit row covers the
prefixed, unprefixed and empty reasons. Mutants prefix-always,
prefix-never and no-fallback.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… manager

The Check PR workflow failed on every pull request at its first step:
borales/actions-yarn@v2.1.0 runs a docker image with no yarn in it
("sh: yarn: not found"). The repo's package manager is npm
(package-lock.json, no yarn.lock), so the check now installs with
actions/setup-node@v4 (Node.js 22, npm cache) and runs npm ci and
npm run build. actions/checkout moves to v4 with it.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…s own

The Node 18 leg failed at "npx playwright install": Playwright 1.62,
the rows' version, needs Node.js 20 or later. Its failure then
cancelled the Node 22 leg, whose 24 rows had all passed, through the
matrix's default fail-fast.

The matrix is now 20, 22 and 24 (the active LTS) with fail-fast off,
so one leg's result never hides another's. package.json's engines
says node >=20 to match, and the README says it.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
… tag

A tag playwright-vX.Y.Z runs the rows on the tagged commit (every
Node.js leg, through playwright-sdk.yml as a called workflow) and then
publishes playwright/ with npm publish --access public --provenance,
from GitHub Actions with the repository secret NPM_TOKEN.

The publish job refuses, each with a named error, before anything is
uploaded:
- a tag that does not name package.json's version exactly, or a
  version that is not a release x.y.z (npm 10 would make a prerelease
  the package's latest): scripts/release-version.mjs, with rows;
- an empty NPM_TOKEN;
- an @keploy:registry that npm would use other than
  registry.npmjs.org (read with every npmrc in it; setup-node pins it);
- a token npm whoami cannot authenticate.
npm itself refuses a version it already has.

package.json gains prepublishOnly: npm run build, so a publish from a
fresh checkout (no dist/) carries its build. On pull requests a dry-run
job runs the same npm publish with no token and fails when the package
would ship without dist/index.js, dist/index.d.ts, package.json or
README.md.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…rule the browser covers

Every behaviour the README states now has a row that fails without it.

Settle, against the rows' page server with Chromium:
- a navigation answered 205 and a download (a navigation answered with
  content-disposition attachment) replace no document, so a call in
  flight across either is still waited for (the test times out naming
  it);
- a call whose page closes is not waited for (the test passes with no
  wait step); nor is a call whose frame is removed, here a cross-site
  frame (localhost under a 127.0.0.1 page), as a payment form's is;
- a navigation's own request stays in flight after its document commits:
  a document still loading is waited for, by name.

The agent client:
- a 307 from the agent is an error, and the call is not sent again to
  where it points;
- an end answered with a status other than ok is an error (begin's was
  rowed, end's was not).

Names:
- an unnamed Playwright project claims with the key "." (the agent
  refuses an empty one) and its tests name no project;
- a spec reached through a symbolic link is named by its real path.

The page server gains /resetcontent (205), /download (an attachment)
and /slowdoc (a document whose last byte waits for /release); the
fixture config takes PW_UNNAMED=1 for an unnamed project.

The removed-frame rule is gone. Settle dropped a removed frame's calls
itself, but Chromium ends them as failed requests: the removed-frame
row passes with that rule taken out, for a same-site frame and for a
cross-site one alike. A rule no row can fail is surface with no proof,
so it goes; the row stays and proves the behaviour. A closed page's
calls get no end from the browser, and that rule stays (its row fails
without it).

Of the review's 17 mutants of the package (16 compile), 9 got past
every row. 8 of them are now each killed: 205, attachment, page closed,
the navigation request kept on commit, redirect followed, end's status,
the "." key and the linked spec. The ninth, frame removed, is the rule
removed above. Proof: rows and mutants on Node.js 22, rows on 20
and 24, in node:<v>-bookworm on a test box.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…mits and tag-only releases

given() posts to /agent/scope/given, which keploy/keploy#5016 adds and
no keploy release serves yet. On a keploy without it, the error said
"use a keploy and a @keploy/playwright of the same release", and no such
release exists. It now says what happened and what is needed:

  keploy: this keploy agent answered 404 to POST /agent/scope/given, so
  it cannot take the given value <name>: given needs a keploy that serves
  that route, which keploy/keploy#5016 adds

Claim, begin, settle and end work with released keploy, so the package
is usable without given.

README:
- Limits: given's route (with the error above), and the third limit the
  package has: the beforeAll and afterAll hooks of a group whose tests
  are all set aside still run, because each test is skipped at its own
  begin.
- Releasing: bump the version in a pull request, then push
  playwright-vX.Y.Z as a plain git tag on main. Never create a GitHub
  release for it: a published release starts every workflow of the
  repository that runs on releases, such as the root @keploy/sdk release
  workflow of #117, which would try to publish under the tag's name. The
  publish workflow's header says the same.
- Run the suite with --retries=0 as well as --workers=1, with the
  reason.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Two settle guards had no row that fails without them:
- A page that closes drops only its own calls. Without that check, a
  popup that closes (an OAuth or payment window) dropped its opener's
  calls in flight, and the opener's context then closed on them. Row:
  "another page closing cancels nothing of this page".
- Only a navigation's response marks a frame as loading. Without that
  check, an answered fetch followed by a route change through the
  history API dropped the frame's calls in flight. Row: "a route change
  after an answered call cancels nothing".

Row: "the test closes its own context" (a page's call, not waited for).
The context's own close rule stays: a later commit rows the call that
only it drops.

README: a closing page cancels only its own calls, the test closing its
own context cancels every call, and the rows that prove which calls the
browser ends itself run in Chromium only (a limit for Firefox and
WebKit).

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…a service worker's call

Three guards had no row that fails without them:
- given turns a 404 into "needs a keploy that serves that route" only
  when the answer is not keploy's own refusal (no error code). A 404 that
  carries keploy's error code, message and remedy now shows them, as any
  other refusal does. Row: the given row's new 404 case.
- A download is a navigation answered with an attachment, in any case
  (RFC 6266): the download row's server now answers "Attachment", so a
  case-sensitive check lets the frame's calls be dropped and fails it.
- A service worker's call has no frame (Playwright's request.frame()
  throws for it). Settle counts it like a page's call and no page change
  drops it. Row: a service worker that calls /slow as it installs keeps
  the test waiting, with a step that names the call.

README: settle counts a service worker's calls.

Rows: 40 (15 unit, 4 release, 21 Playwright). Each mutant of the three
guards fails its row.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…orker, a lowercase download

Three settle rules had no row that fails without them:
- The test closing its own context drops every call in flight. A page's
  calls its page close drops too, but a service worker's call has no
  frame, so no page close drops it, and Chromium ends the worker with
  its context without reporting an end for the call. Row: a service
  worker calls /slow as it installs, then the test closes its own
  context; the test passes at once. Without the rule it waits until the
  test timeout.
- A closing page drops only calls that have a frame in that page. Row:
  a service worker's call in flight while another page of the test
  closes is still waited for, and the step names it.
- A download is a navigation answered with an attachment in any letter
  case. The download row answers "Attachment"; a new row answers the
  common "attachment", so a check for either spelling alone fails one
  of them.

README: settle's service-worker rule names the context close as the one
thing that drops a worker's call.

There are now 43 rows (15 unit, 4 release, 24 Playwright).

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…ncels it

Five settle rows cancel a call in flight (a new document, a removed
frame, a closed page, the test closing its own context, for a page's
call and a service worker's) and then assert that the page server saw
the call. Each spec cancelled the call as soon as the browser's request
event fired. That event comes before the request reaches the server, so
on a loaded box the cancel could win: the test passed for the right
reason, and the row failed because the server never logged "slow sent".
It happened in this branch's gate run (the context-close row, a box at
load 7 to 9 on 16 CPUs). The removed-frame row's one earlier failure,
in the second review's run, kept no detail; that row makes the same
assertion after the same kind of cancel, so this race can explain it.

The page server now answers /seen once /slow has arrived, and each of
those specs waits for /seen before it cancels. The order is decided by
the server's own event, with no time window.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…en needs

keploy/keploy#5016 merged and shipped in keploy v3.6.192, which serves
POST /agent/scope/given only under the proven switch: with the switch
off, the route answers the plain 404 it gave before it existed. The
README said no keploy release served the route, and given's 404 error
told a v3.6.192 user whose switch was off that their keploy lacked it.

The 404 error and the README's limit now say what given needs: keploy
v3.6.192 or later (keploy/keploy#5016), or an enterprise release on
keploy v3.6.192 or later, run with KEPLOY_PROVEN=1. An older keploy, or
one run without the switch, answers 404 there. Enterprise main still pins
keploy v3.6.190, so no enterprise release is named.

Row: the given row's 404 case matches the new error exactly.
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Every cancel in the settle rows came in the test body, before settled()
waited, so no row failed with Inflight.drop's wake removed: a test whose
page closes, or whose context closes, while settle already waits would
then wait until its timeout, against the README's "a call is not waited
for once the browser has cancelled it".

A unit row drives Inflight with a fake browser context (an EventEmitter),
with no browser and no timer. settle() waits for a page's call; another
page's close leaves it waiting; the call's own page closing wakes it. With
a service worker's call in flight too, that page's close leaves settle
waiting for the worker's call, and the test closing its context wakes it.

It fails with drop's wake removed, with wake's empty check removed, with
no context-close rule or one that drops only calls with a frame, and with
a page close that drops every page's calls, none, or a service worker's
call too.

Rows: 44 (16 unit, 4 release, the rest Playwright).
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
keploy speaks scope protocol v1, this package's wire, only when it runs
with KEPLOY_PROVEN=1. With the switch off, keploy's default, the agent
has no POST /agent/instance route and answers the worker's claim with a
plain 404, so every test of the worker fails. The README's commands had
no switch, and named it only for given.

- README "Use": the commands are KEPLOY_PROVEN=1 keploy mock record|replay,
  and the section says once that keploy speaks the package's wire (the
  claim, begin, end and given) only under the switch.
- The claim's plain 404 (no keploy error code) is a named error: the
  route, the switch and the command, or a keploy from before scope
  protocol v1. A 404 that carries keploy's own refusal still shows it.
- given's 404 names only the version (keploy v3.6.192, or an enterprise
  release on it): given runs only in a worker whose claim the agent
  took, so the switch is on there.

Row: a claim answered with a plain 404 names the route and the switch;
one with keploy's own refusal shows that refusal; a plain 500 keeps the
generic text. given's row matches the version-only text.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain marked this pull request as ready for review November 1, 2026 04:20
@slayerjain
slayerjain merged commit 5ce0d3b into main Nov 1, 2026
8 checks passed
@slayerjain
slayerjain deleted the feat/playwright branch November 1, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant