Skip to content

Commit

Permalink
refactor: chrome-launch -> chrome-launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Oct 15, 2019
1 parent 096e05e commit b910da2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $ mocha-chrome --help

Options
--chrome-flags A JSON string representing an array of flags to pass to Chrome
--chrome-launcher Chrome launcher options (see https://github.com/GoogleChrome/chrome-launcher#launchopts)
--chrome-launcher Chrome launcher options (see https://github.com/GoogleChrome/chrome-launcher#launchopts)
--ignore-console Suppress console logging
--ignore-exceptions Suppress exceptions logging
--ignore-resource-errors Suppress resource error logging
Expand All @@ -82,9 +82,11 @@ $ mocha-chrome --help
--version

Examples
$ mocha-chrome test.html --no-colors
$ mocha-chrome test.html --reporter dot
$ mocha-chrome test.html --mocha '{"ui":"tdd"}' --chrome-launcher.maxConnectionRetries=10
$ mocha-chrome test.html --no-colors
$ mocha-chrome test.html --reporter dot
$ mocha-chrome test.html --mocha '\{"ui":"tdd"\}'
$ mocha-chrome test.html --chrome-flags '["--some-flag", "--and-another-one"]'
$ mocha-chrome test.html --chrome-launcher.maxConnectionRetries=10
```

## Events
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MochaChrome {
options = deepAssign(
{
chromeFlags: [],
chromeLaunch: {},
chromeLauncher: {},
loadTimeout: 1000,
logLevel: 'error',
ignoreExceptions: false,
Expand Down
12 changes: 9 additions & 3 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const cli = meow(chalk`{underline Usage}
{underline Options}
--chrome-flags A JSON string representing an array of flags to pass to Chrome
--chrome-launch.xxx=yyy Options for chrome launcher except for chromeFlags and logLevel (see https://github.com/GoogleChrome/chrome-launcher#launchopts)
--chrome-launcher Chrome launcher options (see https://github.com/GoogleChrome/chrome-launcher#launchopts)
--ignore-console Suppress console logging
--ignore-exceptions Suppress exceptions logging
--ignore-resource-errors Suppress resource error logging
Expand Down Expand Up @@ -72,11 +72,17 @@ const useColors = !!flags.colors;
const reporter = flags.reporter || 'spec';
const mocha = Object.assign(JSON.parse(flags.mocha || '{}'), { useColors, reporter });
const chromeFlags = JSON.parse(flags.chromeFlags || '[]');
const { logLevel, ignoreExceptions, ignoreConsole, ignoreResourceErrors } = flags;
const {
chromeLauncher = {},
ignoreExceptions,
ignoreConsole,
ignoreResourceErrors,
logLevel
} = flags;
const loadTimeout = flags.timeout;
const options = {
chromeFlags,
chromeLaunch: flags.chromeLaunch || {},
chromeLauncher,
ignoreExceptions,
ignoreConsole,
ignoreResourceErrors,
Expand Down
2 changes: 1 addition & 1 deletion lib/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = async function createInstance(log, options) {
'--no-first-run'
].concat(options.chromeFlags || []);

const opts = Object.assign({}, options.chromeLaunch, {
const opts = Object.assign({}, options.chromeLauncher, {
chromeFlags: [...new Set(flags)],
logLevel: options.logLevel
});
Expand Down
6 changes: 3 additions & 3 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ describe('mocha-chrome binary', () => {
expect(exitCode).to.equal(0);
});

it('should allow use of --chrome-launch', async () => {
it('should allow use of --chrome-launcher', async () => {
const { exitCode } = await cli(
[
'test/html/test.html',
'--chrome-launch.connectionPollInterval=1500',
'--chrome-launch.maxConnectionRetries=10'
'--chrome-launcher.connectionPollInterval=1500',
'--chrome-launcher.maxConnectionRetries=10'
],
{
cwd
Expand Down

0 comments on commit b910da2

Please sign in to comment.