Skip to content

Commit

Permalink
fix: support --json flag for heartbeat 7.13
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Jul 1, 2021
1 parent f9e28e8 commit c7fc40b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions __tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ describe('CLI', () => {
expect(await cli.exitCode).toBe(1);
});

it('produce json output via --json flag', async () => {
const cli = new CLIMock([
join(FIXTURES_DIR, 'fake.journey.ts'),
'--reporter',
'json',
]);
await cli.waitFor('fake journey');
const output = cli.output();
expect(JSON.parse(output).journey).toEqual({
it('produce json output --json and reporter=json flag', async () => {
const output = async args => {
const cli = new CLIMock([join(FIXTURES_DIR, 'fake.journey.ts'), ...args]);
await cli.waitFor('fake journey');
expect(await cli.exitCode).toBe(0);
return JSON.parse(cli.output());
};
expect((await output(['--reporter', 'json'])).journey).toEqual({
id: 'fake journey',
name: 'fake journey',
});
expect((await output(['--json'])).journey).toEqual({
id: 'fake journey',
name: 'fake journey',
});
expect(await cli.exitCode).toBe(0);
});

it('mimick heartbeat with `--rich-events` flag', async () => {
Expand Down
1 change: 1 addition & 0 deletions src/parse_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ program
'configuration path (default: synthetics.config.js)'
)
.option('-s, --suite-params <jsonstring>', 'suite variables', '{}')
.option('-j, --json', 'output newline delimited JSON')
.addOption(
new Option('--reporter <value>', `output repoter format`).choices(
Object.keys(reporters)
Expand Down

0 comments on commit c7fc40b

Please sign in to comment.