jest-ban-console

1.0.0 • Public • Published

jest-ban-console

Ban console from being called in Jest tests.

How to use

First, install into your project:

$ npm install --save-dev jest-ban-console || yarn add --dev jest-ban-console

Then, ban console from individual tests:

import { jestBanConsole } from "jest-ban-console";

describe("your module", () => {
  jestBanConsole();
});

If you want to enforce this across all of your tests, run it in your setupTests.js or similar:

import { jestBanConsole } from "jest-ban-console";

jestBanConsole();

API

installConsoleProxy: () => void

Installs the proxy console for intercepting calls to the console. Also clears any mock calls on the proxy.

clearConsole: () => void

Clears any mock calls on the console.

expectConsoleBan: () => void

Checks all of the console methods to see if any of them have been called. If so, throws an AggregateError with an array of errors for each console method called.

resetConsole: () => void

Resets the global console back to the real console implementation.

Package Sidebar

Install

npm i jest-ban-console

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.29 kB

Total Files

5

Last publish

Collaborators

  • jamesdigioia