From 8e80f8cef501e8d92ce6df937d52fa9c7d149d44 Mon Sep 17 00:00:00 2001 From: Sergio Moya <1083296+smoya@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:52:03 +0200 Subject: [PATCH] list browsers --- test/browser/browser.spec.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index b484185e3..d7189790a 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -2,6 +2,8 @@ import fs from 'fs'; import http from 'http'; import path from 'path'; import url from 'url'; +import os from 'os'; +import * as child_process from 'child_process'; import puppeteer from 'puppeteer'; describe('Test browser Parser in the node env', function() { @@ -10,6 +12,27 @@ describe('Test browser Parser in the node env', function() { let page: puppeteer.Page; beforeAll(async function() { + // if MacOS M1/M2, provide your own path to chromium + if (os.platform() === 'darwin' && os.arch() === 'arm64') { + try { + const browsers = child_process + .execSync('ll ~/.cache/puppeteer') + .toString() + .replace('\n', ''); + if (!browsers) { + throw new Error( + 'error listing browsers!' + ); + } + console.log('BROWSERS:', browsers); + } catch (error) { + console.error(error); + console.log( + '\n\nUnable to find browsers\n\n' + ); + throw error; + } + } const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const htmlPath = path.resolve(__dirname, 'sample-page.html'); const parserScript = path.resolve(__dirname, '../../browser/index.js');