Skip to content

Commit

Permalink
Use proper command in executeCli-test
Browse files Browse the repository at this point in the history
In order to test the output of the cli command, we need to stop using
the js module directly. Instead, we can use the built cli.js file. This
is the same file that users end up invoking when running `happo run`.
  • Loading branch information
trotzig committed Jan 7, 2020
1 parent a00e2ae commit a22b0ec
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/executeCli-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import commander from 'commander';
import { execSync } from 'child_process';

import executeCli from '../src/executeCli';

beforeEach(() => {
commander.help = jest.fn();
});
const happoCommand = require.resolve('../build/cli');

it('displays help when no command is given', () => {
executeCli(['node', 'happo']);
expect(commander.help.mock.calls.length).toBe(1);
const result = execSync(happoCommand, { encoding: 'utf-8' });
expect(result).toMatch(/^Usage: /);
});

0 comments on commit a22b0ec

Please sign in to comment.