Skip to content

Chrome DevTools for coding agents

test: installing chrome through test script (#1085)

Nicholas Roscino8dbf8625498c
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index cab31d9e..8aa274f0 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -41,12 +41,6 @@ jobs:
shell: bash
run: npm ci
- - name: Install Chrome Canary
- shell: bash
- run: |
- CANARY_PATH=$(npx @puppeteer/browsers install chrome@canary --format "{{path}}")
- echo "CANARY_EXECUTABLE_PATH=$CANARY_PATH" >> $GITHUB_ENV
-
- name: Build
run: npm run bundle
env:
diff --git a/scripts/test.mjs b/scripts/test.mjs
index 43ee3871..7a00c115 100644
--- a/scripts/test.mjs
+++ b/scripts/test.mjs
@@ -7,7 +7,7 @@
// Note: can be converted to ts file once node 20 support is dropped.
// Node 20 does not support --experimental-strip-types flag.
-import {spawn} from 'node:child_process';
+import {spawn, execSync} from 'node:child_process';
import path from 'node:path';
import process from 'node:process';
@@ -58,6 +58,19 @@ const nodeArgs = [
...files,
];
+function installChrome(version) {
+ try {
+ return execSync(
+ `npx @puppeteer/browsers install chrome@${version} --format "{{path}}"`,
+ )
+ .toString()
+ .trim();
+ } catch (e) {
+ console.error(`Failed to install Chrome ${version}:`, e);
+ process.exit(1);
+ }
+}
+
async function runTests(attempt) {
if (attempt > 1) {
console.log(`\nRun attempt ${attempt}...\n`);
@@ -78,6 +91,9 @@ async function runTests(attempt) {
});
}
+const chromePath = installChrome('146.0.7680.31');
+process.env.CHROME_M146_EXECUTABLE_PATH = chromePath;
+
const maxAttempts = shouldRetry ? 3 : 1;
let exitCode = 1;
diff --git a/tests/tools/extensions.test.ts b/tests/tools/extensions.test.ts
index 61f85b90..dbea68e3 100644
--- a/tests/tools/extensions.test.ts
+++ b/tests/tools/extensions.test.ts
@@ -149,7 +149,7 @@ describe('extension', () => {
assert.ok(pageTargetAfter, 'Page should exist after action');
},
{
- executablePath: process.env.CANARY_EXECUTABLE_PATH,
+ executablePath: process.env.CHROME_M146_EXECUTABLE_PATH,
},
{
categoryExtensions: true,