Skip to content

Commit 0208bfd

Browse files
fix: expose timeout when Emulation is enabled (#73)
Co-authored-by: Alex Rudenko <[email protected]>
1 parent 91d83c4 commit 0208bfd

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
},
99
"main": "index.js",
1010
"scripts": {
11-
"build": "tsc && node --experimental-strip-types scripts/post-build.ts",
11+
"build": "tsc && node --experimental-strip-types --no-warnings=ExperimentalWarning scripts/post-build.ts",
1212
"typecheck": "tsc --noEmit",
1313
"format": "eslint --cache --fix . && prettier --write --cache .",
1414
"check-format": "eslint --cache . && prettier --check --cache .;",
1515
"docs": "npm run build && npm run docs:generate && npm run format",
1616
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
1717
"start": "npm run build && node build/src/index.js",
1818
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
19-
"test": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
20-
"test:only": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
21-
"test:only:no-build": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
22-
"test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
19+
"test": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
20+
"test:only": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
21+
"test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
22+
"test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
2323
"prepare": "node --experimental-strip-types scripts/prepare.ts"
2424
},
2525
"files": [

src/McpContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ export class McpContext implements Context {
243243
page.setDefaultNavigationTimeout(NAVIGATION_TIMEOUT * networkMultiplier);
244244
}
245245

246+
getNavigationTimeout() {
247+
const page = this.getSelectedPage();
248+
return page.getDefaultNavigationTimeout();
249+
}
250+
246251
async getElementByUid(uid: string): Promise<ElementHandle<Element>> {
247252
if (!this.#textSnapshot?.idToNode.size) {
248253
throw new Error('No snapshot found. Use browser_snapshot to capture one');

src/McpResponse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export class McpResponse implements Response {
117117
if (networkConditions) {
118118
response.push(`## Network emulation`);
119119
response.push(`Emulating: ${networkConditions}`);
120+
response.push(
121+
`Navigation timeout set to ${context.getNavigationTimeout()} ms`,
122+
);
120123
}
121124

122125
const cpuThrottlingRate = context.getCpuThrottlingRate();

tests/McpResponse.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ uid=1_0 RootWebArea "My test page"
104104
result[0].text,
105105
`# test response
106106
## Network emulation
107-
Emulating: Slow 3G`,
107+
Emulating: Slow 3G
108+
Navigation timeout set to 100000 ms`,
108109
);
109110
});
110111
});

0 commit comments

Comments
 (0)