Skip to content

Commit

Permalink
fix(cli): display stack trace on errors by default (dequelabs#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-siek authored Aug 30, 2022
1 parent 17c9437 commit a47100c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
26 changes: 21 additions & 5 deletions packages/cli/src/bin/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,31 @@ describe('cli', () => {
});

describe('--show-errors', () => {
it('should log the time it takes to run', async () => {
it('should log the time it takes to run defaults to show errors', async () => {
const result = await runCLI(
`file://${SIMPLE_HTML_FILE}`,
'--show-errors'
'--include',
'#hazaar'
);
assert.equal(result.exitCode, 0);
assert.equal(result.exitCode, 1);
assert.include(
result.stdout,
'Violation of "marquee" with 1 occurrences!'
result.stderr,
'Error: JavascriptError: javascript error:'
);
});

it('do not show errors when passed false', async () => {
const result = await runCLI(
`file://${SIMPLE_HTML_FILE}`,
'--include',
'#hazaar',
'--show-errors',
'false'
);
assert.equal(result.exitCode, 1);
assert.include(
result.stderr,
'An error occurred while testing this page.'
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ program
'Set how much time (seconds) axe has to run (default: 90)'
)
.option('--timer', 'Log the time it takes to run')
.option('--show-errors', 'Display the full error stack')
.option('--show-errors [boolean]', 'Display the full error stack', true)
// TODO: Replace this with a reporter option, this required adding
.option('--no-reporter', 'Turn the CLI reporter off')
.option(
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const cli = async (
dir,
exit,
timer,
showErrors,
reporter: noReporter,
chromeOptions,
verbose,
Expand All @@ -40,6 +39,8 @@ const cli = async (
chromedriverPath
} = args;

const showErrors = args.showErrors === true;

const silentMode = !!stdout;
args.axeSource = getAxeSource(args.axeSource);

Expand Down

0 comments on commit a47100c

Please sign in to comment.