Skip to content

Commit

Permalink
Merge pull request #53 from freak2geek/support-latest-drivers
Browse files Browse the repository at this point in the history
Support latest browser versions
  • Loading branch information
StorytellerCZ authored Sep 27, 2023
2 parents 5f96012 + 9269956 commit ced7704
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@ When using your test driver package, you will need to install the necessary NPM

### Puppeteer

`puppeteer@^19.11.1` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default).

```bash
$ npm i --save-dev puppeteer@^1.5.0
$ npm i --save-dev puppeteer@^19.11.1
$ TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package <your package name>
```

### Playwright

`playwright@^1.33.0` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default).

```bash
$ npm i --save-dev playwright@^1.33.0
$ TEST_BROWSER_DRIVER=playwright meteor test --once --driver-package <your package name>
```

Use `PLAYWRIGHT_BROWSER` env to select the browser to use for testing. By default, it uses `chromium`.

### Selenium ChromeDriver

Meteor 1.6+:
Expand Down
4 changes: 3 additions & 1 deletion browser/chromedriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default function startChrome({
// Can't hide the window but can move it off screen
driver.manage().window().setRect(20000, 20000);

const LogsArgsRegex = /"([^"]*)"|(\b\d+\b)/g;

// We periodically grab logs from Chrome and pass them back.
// Every time we call this, we get only the log entries since
// the previous time we called it.
Expand All @@ -70,7 +72,7 @@ export default function startChrome({
stderr(`[ERROR] ${message}`);
} else {
function extractArgs(str) {
let rex = /"([^"]*)"|(\b\d+\b)/g;
let rex = LogsArgsRegex;
let match;
let args = [];
while ((match = rex.exec(str)) !== null) {
Expand Down
7 changes: 6 additions & 1 deletion browser/nightmare.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const TWENTY_DAYS = 1000 * 60 * 60 * 24 * 20;

let nightmare;

process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;

// Make sure the nightmare process does not stick around
process.on('exit', () => {
if (nightmare) {
Expand Down Expand Up @@ -65,7 +67,10 @@ export default function startNightmare({

// Meteor will call the `runTests` function exported by the driver package
// on the client as soon as this page loads.
.goto(process.env.ROOT_URL)
.goto(process.env.ROOT_URL, {
'http-equiv': 'Content-Security-Policy',
content: 'script-src \'unsafe-eval\'',
})

// After the page loads, the tests are running. Eventually they
// finish and the driver package is supposed to set window.testsDone
Expand Down
1 change: 1 addition & 0 deletions browser/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function startPuppeteer({
// --no-sandbox and --disable-setuid-sandbox allow this to easily run in docker
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
headless: 'new',
});
console.log(await browser.version());
const page = await browser.newPage();
Expand Down

0 comments on commit ced7704

Please sign in to comment.