Skip to content

fix(playwright): report given caller paths with spaces - #124

Open
Pranav-Bobde wants to merge 1 commit into
keploy:mainfrom
Pranav-Bobde:fix/given-source-path
Open

Pranav-Bobde wants to merge 1 commit into
keploy:mainfrom
Pranav-Bobde:fix/given-source-path

Conversation

@Pranav-Bobde

Copy link
Copy Markdown

Problem

given() sends its caller as a project-relative file and line in the /agent/scope/given request, and the Keploy agent keeps it as the given value's Source (pkg/service/agent/given_proven.go in keploy/keploy). With spaces in the spec path, sourceOf() can skip the caller and use a lower Playwright frame. In the regression row on main, the request's source is node_modules/playwright/lib/worker/workerProcessEntry.js:1644 instead of test/fixtures/given caller with spaces.spec.ts:4.

The cause is the location regex, which stops at whitespace, and new URL(...).pathname, which leaves %20 in file:// paths.

Change

  • Allow spaces in the location, and remove the at or at async prefix on frames with no function name.
  • Decode file:// URLs with fileURLToPath(). A label it can't decode, such as an eval frame's file:///proj/a%2Fb.spec.ts, is skipped so given() doesn't throw.

Checked

  • New row in playwright/test/rows.test.mjs: it runs a real spec with spaces in its filename against the local fake agent and checks the /agent/scope/given request. It fails on main with the Playwright path above and passes with this change.
  • New sourceOf assertions cover encoded file:// paths, unnamed paths with spaces, at async paths with and without spaces, and an undecodable eval label. The Playwright row covers the spec filename with spaces.
  • With playwright/src/index.ts from main, 2 Playwright tests fail: the new row and the sourceOf unit test.
  • With this change: root build and tests, Jest and Playwright suites all pass on Node 22.23.4, with Playwright on headless Chromium.
  • Not run: jest/e2e/lane.sh, the lane against a live Keploy agent, which needs a newer enterprise Keploy binary than I have.

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