2.9.0 • Published 6 years ago

jest-plugin-console-matchers v2.9.0

Weekly downloads
217
License
MIT
Repository
github
Last release
6 years ago

jest-plugin-console-matchers

npm npm npm

Adds jest matchers for watching console methods.

Getting Started

Install jest-plugin-console-matchers using yarn:

yarn add --dev jest-plugin-console-matchers

Matchers

Adds the following matchers which check for console methods to be called:

MatcherMethod
toConsoleErrorconsole.error
toConsoleInfoconsole.info
toConsoleLogconsole.log
toConsoleWarnconsole.warn
toThrowWarningwarning

Usage

If you want, you can import the matchers to install them in a set of tests.

import 'jest-plugin-console-matchers/setup';

If you want to install the matchers globally, you can modify the jest section of your package.json to include:

"jest": {
  "setupFiles": [
    "jest-plugin-console-matchers/setup"
  ]
}

Example

Example spec that uses these matchers.

import 'jest-plugin-console-matchers/setup';

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 plugin could be better, create an Issue or submit a PR.

2.9.0

6 years ago

2.8.2

6 years ago

2.8.1

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.1

6 years ago

2.5.0

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.4

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.8.3

7 years ago

1.8.0

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.0.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago