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

Add option to filter tests #177

Merged
merged 2 commits into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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