fail-tests-on-text

A utility that fails your tests when some text is logged during execution

Usage no npm install needed!

<script type="module">
  import failTestsOnText from 'https://cdn.skypack.dev/fail-tests-on-text';
</script>

README

fail-tests-on-text

npm version Dependency Status Open Source Love

Need to fail your tests when some text is output?

We use this because we were tired of React warnings slipping into our code base unnoticed.

1. Install

npm install --save-dev fail-tests-on-text

2. Use

import failTestsOnText from 'fail-tests-on-text';

failTestsOnText('Warning:'); // In your test setup somewhere. This works great for catching React warnings (but will catch other stuff too!)

3. Profit

Now any test that causes a React warning to be logged to the console will fail.

Tested with Mocha and Tape using React 16.

Licence

MIT