Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
fix: log "iframe warning" to stderr (#102)
Browse files Browse the repository at this point in the history
This patch moves the "iframe warning" log to stderr (from stdout).

Ref: dequelabs/axe-cli#87
  • Loading branch information
stephenmathieson authored Mar 6, 2019
1 parent 417f4ae commit bb4fb2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/axe-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AxeInjector {

this.didLogError = true;
// eslint-disable-next-line no-console
console.log('Failed to inject axe-core into one of the iframes!');
console.error('Failed to inject axe-core into one of the iframes!');
}

// Get axe-core source (and configuration)
Expand Down
17 changes: 16 additions & 1 deletion test/unit/axe-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,24 @@ describe('AxeInjector', () => {
});

describe('errorHandler', () => {
// See https://github.com/dequelabs/axe-cli/issues/87.
it('writes to stderr (not stdout)', () => {
const injector = new AxeInjector({ driver: new MockWebDriver() });
const logSpy = sinon.spy(console, 'log');
const errorSpy = sinon.spy(console, 'error');

injector.errorHandler();

assert.equal(logSpy.callCount, 0);
logSpy.restore();

assert.equal(errorSpy.callCount, 1);
errorSpy.restore();
});

it('only logs once', () => {
const injector = new AxeInjector({ driver: new MockWebDriver() });
const spy = sinon.spy(console, 'log');
const spy = sinon.spy(console, 'error');

injector.errorHandler();
injector.errorHandler();
Expand Down

0 comments on commit bb4fb2c

Please sign in to comment.