Skip to content
/ chroco Public

[experimental] Chroco operates `puppeteer` with commandable, pluggable settings.

License

Notifications You must be signed in to change notification settings

tkdn/chroco

Repository files navigation

Chroco

Chroco operates `puppeteer` with commandable, pluggable settings.
Chroco [pronounced as "kuroko"] means "black person"/"black clothes" in Japanese. Wikipedia: 黒子
[Work in Progress] It's a experimental package. Help us.

Installation and Usage

Installation

$ yarn add chroco
# or
$ npm i chroco

Programmable Usage

const { excecuter } = require('chroco')
executor({
  // your options, settings and scenarios
})

CLI Usage

$ chroco # default, detect `.chrocorc`
# or
$ chroco --config ./path/to/.chrocorc
# or (if you want, you can use yaml file.)
$ chroco --config .chroco.yml

Default value is .chrocorc.
refs: .chrocorc or .chrocorc.yml

Chroco Configure

Configure should be Object.

parms detail type val required
options refs: puppeteer launch options Object - none
options.logLevel Chroco original options Array.<string>|string ['info', 'warn', 'error'] none
emulateOptions refs: puppeteer emulate options Object - none
receivers Your Customized Receiver, sample Array.<Function> - none
scenarios Your commandable, iterable Array Array.<Object.<Function>.<Array|Object|string> - required

Scenarios <Array>

  • scenarios[n].<Function> is puppeteer's "class: Page" method.
  • scenarios[n].<Function>.<Array|Object|string> is params for above method.
{
  scenarios: [
    goto: [
      'https://www.google.com',
      { waitUntil: 'load' }
    ],
    screenshot: {
      path: 'temp/screenshot.png',
      fullPage: true
    }
  ]
}

This commands executes ...

/**
 * Before commands executed,
 * Chroco executes launching Chrome instance and
 * delivering `puppeteer's page: class` to commands as internal param. 
 */

// const chrome = await puppeteer.launc()
// const page = await chrome.newPage()

await page.goto(
  'https://www.google.com',
  { waitUntil: 'load' }
)
await page.screenshot({
  path: 'temp/screenshot.png',
  fullPage: true
})

Each Scenario's key is mapped to class: Page method with puppeteer.

About

[experimental] Chroco operates `puppeteer` with commandable, pluggable settings.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published