Skip to content

Commit

Permalink
Merge pull request #319 from wondersloth/feat-puppeteer-options
Browse files Browse the repository at this point in the history
Option for sandboxArgs; passing options to puppeteer
  • Loading branch information
vladikoff authored May 4, 2020
2 parents 7545819 + 1dccda6 commit f4d996b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ Default: `'full'`
* `short` only displays a success or failure character for each test (useful with large suites)
* `none` displays nothing

#### options.sandboxArgs
Type: `Object`
Default: `{ args: [] }`

Pass arugments to puppeteer launcher. For the list of available options, please look at [puppeteer launch options](https://pptr.dev/#?product=Puppeteer&version=v3.0.1&show=api-puppeteerlaunchoptions).

Example `sandboxArgs` object:
```js
{
args: {
'=-allow-file-access-from-files'
},
executeablePath: '/some/other/path/to/chrome'
}
```


#### options.summary
Type: `Boolean`
Default: `false`
Expand Down Expand Up @@ -313,6 +330,33 @@ grunt.initConfig({
});
```

#### Passing options to sandbox (puppeteer)

See [puppeteer launch options](https://pptr.dev/#?product=Puppeteer&version=v3.0.1&show=api-puppeteerlaunchoptions) for a complete list of arguments.

```js
// Example configuration
grunt.initConfig({
jasmine: {
customTemplate: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
template: 'custom.tmpl',
sandboxArgs: {
args: ['--no-sandbox'],
timeout: 3000,
defaultViewport: {
isMobile: true
}
}
}
}
}
});
```


## Release History

Expand Down
5 changes: 4 additions & 1 deletion tasks/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ module.exports = function(grunt) {
junit: {},
ignoreEmpty: grunt.option('force') === true,
display: 'full',
sandboxArgs: { args: [] },
summary: false
});

Expand Down Expand Up @@ -144,7 +145,9 @@ module.exports = function(grunt) {
file = `file://${path.join(process.cwd(), file)}`;
}

let puppeteerLaunchSetting;
let puppeteerLaunchSetting = options.sandboxArgs || {};

// Drop these at major, to remove the option.
if(options.hasOwnProperty('noSandbox') && options.noSandbox){
puppeteerLaunchSetting = {args: ['--no-sandbox']};
delete options.noSandbox;
Expand Down

0 comments on commit f4d996b

Please sign in to comment.