1.1.0 • Published 7 years ago
jest-console-matchers v1.1.0
jest-console-matchers
Adds jest
matchers for watching console
methods.
Getting Started
Install jest-console-matchers
using yarn
:
yarn add --dev jest-console-matchers
Matchers
Adds the following matchers which check for console
methods to be called:
Matcher | Method |
---|---|
toConsoleDebug | console.debug |
toConsoleError | console.error |
toConsoleLog | console.log |
toConsoleWarn | console.warn |
toThrowWarning | warning |
Usage
Example spec that uses these matchers.
import 'jest-console-matchers';
describe('User', () => {
set('user', () => new User());
describe('.sayHello', () => {
it('logs hello', () => {
expect(() => user.sayHello()).toConsoleLog();
});
});
describe('.delete', () => {
it('warns about deleting', () => {
expect(() => user.delete()).toConsoleWarn();
});
});
});
Contributing
If you have any ideas on how this package could be better, create an Issue or submit a PR.