From 1dccda6bf63ed042483056c20ff917c44663d15f Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Mon, 4 May 2020 12:19:54 -0700 Subject: [PATCH] options.sandboxArgs; passing options to puppeteer --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ tasks/jasmine.js | 5 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 048c544..60fce6c 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 diff --git a/tasks/jasmine.js b/tasks/jasmine.js index 44e8402..b6dd4ea 100644 --- a/tasks/jasmine.js +++ b/tasks/jasmine.js @@ -91,6 +91,7 @@ module.exports = function(grunt) { junit: {}, ignoreEmpty: grunt.option('force') === true, display: 'full', + sandboxArgs: { args: [] }, summary: false }); @@ -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;