Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maadhattah/jest-ban-console
Ban console from being called in Jest tests
https://github.com/maadhattah/jest-ban-console
Last synced: 29 days ago
JSON representation
Ban console from being called in Jest tests
- Host: GitHub
- URL: https://github.com/maadhattah/jest-ban-console
- Owner: mAAdhaTTah
- Created: 2021-08-29T17:55:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-29T19:27:51.000Z (over 3 years ago)
- Last Synced: 2024-11-20T13:56:23.287Z (about 1 month ago)
- Language: JavaScript
- Size: 44.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jest-ban-console
Ban console from being called in Jest tests.
## How to use
First, install into your project:
```bash
$ npm install --save-dev jest-ban-console || yarn add --dev jest-ban-console
```Then, ban console from individual tests:
```js
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:
```js
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.