Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #177 from zapier/test-grep
Browse files Browse the repository at this point in the history
Add option to filter tests
  • Loading branch information
FokkeZB authored Nov 6, 2017
2 parents 7b0d7fe + 00f900f commit 0b858d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,8 @@ <h2 id="test">test</h2>
<p>Tests your app via <code>npm test</code>.</p>
</blockquote><p> <strong>Usage:</strong> <code>zapier test</code></p><p>This command is effectively the same as <code>npm test</code>, except we also validate your app and set up the environment. We recommend using mocha as your testing framework.</p><p><strong>Arguments</strong></p><ul>
<li><code>--debug</code> -- <em>optional</em>, print zapier detailed logs to standard out</li>
<li><code>--timeout=value</code> -- <em>optional</em>, add a default timeout to mocha, in milliseconds</li>
<li><code>--timeout=value</code> -- <em>optional</em>, set test-case timeout in milliseconds [2000]</li>
<li><code>--grep=value</code> -- <em>optional</em>, only run tests matching pattern</li>
<li><code>--skip-validate</code> -- <em>optional</em>, forgo running <code>zapier validate</code> before <code>npm test</code></li>
</ul>
</div>
Expand Down
3 changes: 2 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ This command is effectively the same as `npm test`, except we also validate your


* `--debug` -- _optional_, print zapier detailed logs to standard out
* `--timeout=value` -- _optional_, add a default timeout to mocha, in milliseconds
* `--timeout=value` -- _optional_, set test-case timeout in milliseconds [2000]
* `--grep=value` -- _optional_, only run tests matching pattern
* `--skip-validate` -- _optional_, forgo running `zapier validate` before `npm test`

```bash
Expand Down
14 changes: 11 additions & 3 deletions src/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ const test = (context) => {
const env = _.extend({}, process.env, extraEnv);
const commands = ['run', '--silent', 'test'];

if (global.argOpts.timeout) {
if (global.argOpts.timeout || global.argOpts.grep) {
commands.push('--');
commands.push(`--timeout=${global.argOpts.timeout}`);

if (global.argOpts.timeout) {
commands.push(`--timeout=${global.argOpts.timeout}`);
}

if (global.argOpts.grep) {
commands.push(`--grep=${global.argOpts.grep}`);
}
}

context.line('Running test suite.');
Expand All @@ -51,7 +58,8 @@ test.argsSpec = [
];
test.argOptsSpec = {
debug: {flag: true, help: 'print zapier detailed logs to standard out'},
timeout: {help: 'add a default timeout to mocha, in milliseconds'},
timeout: {help: 'set test-case timeout in milliseconds [2000]'},
grep: {help: 'only run tests matching pattern'},
'skip-validate': {flag: true, help: 'forgo running `zapier validate` before `npm test`'},
};
test.help = 'Tests your app via `npm test`.';
Expand Down

0 comments on commit 0b858d9

Please sign in to comment.