diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 6386411c2..a77ebd406 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,26 @@ 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 executablePath = child_process + .execSync('which chromium') + .toString() + .replace('\n', ''); + if (!executablePath) { + throw new Error( + 'Could not find chromium executable!' + ); + } + } catch (error) { + console.error(error); + console.log( + '\n\nUnable to find chromium path for you MacOS Arm64 machine\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'); @@ -40,7 +62,7 @@ describe('Test browser Parser in the node env', function() { console.info('navigating to localhost'); await page.goto('http://localhost:8080', { waitUntil: 'networkidle0' }); - }, 20000); + }); afterAll(async function() { await browser.close();