Permalink
Browse files

add options arg to Puppeteer.defaultArgs

  • Loading branch information...
zploskey committed Aug 13, 2018
1 parent 2505627 commit 0fb495d23bc620d5644e75d3f898ba3f5b16ce20
Showing with 53 additions and 5 deletions.
  1. +8 −2 __tests__/puppeteer_test.re
  2. +7 −2 lib/js/__tests__/puppeteer_test.js
  3. +20 −0 lib/js/src/Puppeteer.js
  4. +18 −1 src/Puppeteer.re
@@ -41,12 +41,18 @@ let testPageContent = Node.Fs.readFileAsUtf8Sync(testPagePath);
let noSandbox = Puppeteer.makeLaunchOptions(~args=[|"--no-sandbox"|], ());

describe("Puppeteer", () => {
open Puppeteer;
test("executablePath", () =>
Puppeteer.executablePath() |> expect |> toContainString("chromium")
executablePath() |> expect |> toContainString("chromium")
);
test("defaultArgs()", () =>
Puppeteer.defaultArgs() |> Array.length |> expect |> toBeGreaterThan(0)
defaultArgs() |> Array.length |> expect |> toBeGreaterThan(0)
);
test("calling defaultArgs with options", () => {
let options = DefaultArgsOptions.make(~headless=true, ());
let args = defaultArgs(~options, ());
args |> Array.length |> expect |> toBeGreaterThan(0);
});
});

describe("BrowserFetcher", () => {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -78,9 +78,26 @@ external makeLaunchOptions:
external launch: (~options: launchOptions=?, unit) => Js.Promise.t(Browser.t) =
"";

module DefaultArgsOptions = {
[@bs.deriving abstract]
type t = {
[@bs.optional]
headless: bool,
[@bs.optional]
args: array(string),
[@bs.optional]
userDataDir: string,
[@bs.optional]
devtools: bool,
};
let make = t;
};

/** The default flags that Chromium will launch with. */
[@bs.val] [@bs.module "puppeteer"]
external defaultArgs: unit => array(string) = "";
external defaultArgs:
(~options: DefaultArgsOptions.t=?, unit) => array(string) =
"";

type browserFetcherOptions = {
.

0 comments on commit 0fb495d

Please sign in to comment.