Skip to content

Commit 8dbf862

Browse files
authored
test: installing chrome through test script (#1085)
Fixes local test failing for triggerAction on extensions.
1 parent bedfd5d commit 8dbf862

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
shell: bash
4242
run: npm ci
4343

44-
- name: Install Chrome Canary
45-
shell: bash
46-
run: |
47-
CANARY_PATH=$(npx @puppeteer/browsers install chrome@canary --format "{{path}}")
48-
echo "CANARY_EXECUTABLE_PATH=$CANARY_PATH" >> $GITHUB_ENV
49-
5044
- name: Build
5145
run: npm run bundle
5246
env:

scripts/test.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Note: can be converted to ts file once node 20 support is dropped.
88
// Node 20 does not support --experimental-strip-types flag.
99

10-
import {spawn} from 'node:child_process';
10+
import {spawn, execSync} from 'node:child_process';
1111
import path from 'node:path';
1212
import process from 'node:process';
1313

@@ -58,6 +58,19 @@ const nodeArgs = [
5858
...files,
5959
];
6060

61+
function installChrome(version) {
62+
try {
63+
return execSync(
64+
`npx @puppeteer/browsers install chrome@${version} --format "{{path}}"`,
65+
)
66+
.toString()
67+
.trim();
68+
} catch (e) {
69+
console.error(`Failed to install Chrome ${version}:`, e);
70+
process.exit(1);
71+
}
72+
}
73+
6174
async function runTests(attempt) {
6275
if (attempt > 1) {
6376
console.log(`\nRun attempt ${attempt}...\n`);
@@ -78,6 +91,9 @@ async function runTests(attempt) {
7891
});
7992
}
8093

94+
const chromePath = installChrome('146.0.7680.31');
95+
process.env.CHROME_M146_EXECUTABLE_PATH = chromePath;
96+
8197
const maxAttempts = shouldRetry ? 3 : 1;
8298
let exitCode = 1;
8399

tests/tools/extensions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('extension', () => {
149149
assert.ok(pageTargetAfter, 'Page should exist after action');
150150
},
151151
{
152-
executablePath: process.env.CANARY_EXECUTABLE_PATH,
152+
executablePath: process.env.CHROME_M146_EXECUTABLE_PATH,
153153
},
154154
{
155155
categoryExtensions: true,

0 commit comments

Comments
 (0)