From 7cadc382bc12a6641d048b277d49d6440da9cb46 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Tue, 20 Nov 2018 14:24:08 -0800 Subject: [PATCH] Add debug option --- .gitignore | 1 + README.md | 26 ++++++++++++++++++++++++++ src/cli.js | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/.gitignore b/.gitignore index 301132b..f0bbd74 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ package-lock.json dist build coverage +.vscode diff --git a/README.md b/README.md index e19ae8c..58f64f8 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,32 @@ karmatic '**/*Spec.jsx?' ``` +## Usage + +```text +Usage + $ karmatic [options] + +Available Commands + run Run tests once and exit + watch Run tests on any change + debug Open a headful Puppeteer instance for debugging your tests + +For more info, run any command with the `--help` flag + $ karmatic run --help + $ karmatic watch --help + +Options + -v, --version Displays current version + --files Minimatch pattern for test files + --headless Run using Chrome Headless (default true) + --coverage Report code coverage of tests (default true) + -h, --help Displays this message +``` + +NOTE: The `debug` option overrides the default value of the `--headless` and `--coverage` option to be `false`. This option will also open up the local Puppeteer installation of Chrome, not your globally installed one. If you'd like to debug your tests using your your own instance of Chrome (or any other browser), copy the URL from the puppeteer window into your favorite browser. + + ## FAQ **Q**: [Is there an FAQ?](https://twitter.com/gauntface/status/956259291928776704)** diff --git a/src/cli.js b/src/cli.js index 5d4e789..6a02a04 100644 --- a/src/cli.js +++ b/src/cli.js @@ -28,6 +28,13 @@ prog .describe('Run tests on any change') .action( (str, opts) => run(str, opts, true) ); +prog + .command('debug [...files]') + .describe('Open a headful Puppeteer instance for debugging your tests') + .option('--headless', 'Run using Chrome Headless', false) // Override default to false + .option('--coverage', 'Report code coverage of tests', false) // Override default to false + .action( (str, opts) => run(str, opts, true) ); + prog.parse(process.argv); function run(str, opts, isWatch) {