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

Commit bb4fb2c

Browse files
fix: log "iframe warning" to stderr (#102)
This patch moves the "iframe warning" log to stderr (from stdout). Ref: dequelabs/axe-cli#87
1 parent 417f4ae commit bb4fb2c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/axe-injector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AxeInjector {
1717

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

2323
// Get axe-core source (and configuration)

test/unit/axe-injector.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,24 @@ describe('AxeInjector', () => {
4646
});
4747

4848
describe('errorHandler', () => {
49+
// See https://github.com/dequelabs/axe-cli/issues/87.
50+
it('writes to stderr (not stdout)', () => {
51+
const injector = new AxeInjector({ driver: new MockWebDriver() });
52+
const logSpy = sinon.spy(console, 'log');
53+
const errorSpy = sinon.spy(console, 'error');
54+
55+
injector.errorHandler();
56+
57+
assert.equal(logSpy.callCount, 0);
58+
logSpy.restore();
59+
60+
assert.equal(errorSpy.callCount, 1);
61+
errorSpy.restore();
62+
});
63+
4964
it('only logs once', () => {
5065
const injector = new AxeInjector({ driver: new MockWebDriver() });
51-
const spy = sinon.spy(console, 'log');
66+
const spy = sinon.spy(console, 'error');
5267

5368
injector.errorHandler();
5469
injector.errorHandler();

0 commit comments

Comments
 (0)