A Babel plugin (v0.1.0) that automatically inserts `expect.assertions(n)` and `expect.hasAssertions()` into Jest test blocks by counting `expect` calls. It supports sync, async, arrow, named, and only tests, including `beforeEach`/`afterEach` blocks. Unlike manual insertion, it eliminates human error and verbosity. Current stable version is 0.1.0; no major releases planned. Minimal alternative to manual assertion count management.
npm install babel-jest-assertionsVerified import paths — ran on the pinned version, not inferred.
Shows Babel plugin configuration and how the plugin transforms a test with two assertions.
Manually add `expect.assertions(n)` if the count is off, or avoid complex expect chains.
Use manual `expect.assertions(0)` or disable plugin for dynamic cases.
Review tests that have assertions in lifecycle hooks; adjust expected counts or add assertions.
Ensure test blocks use standard `it`, `test`, `xit`, `fit`, `it.only` only.
Downgrade to Babel 6 or use the Babel 7 compatible fork of this plugin.
Add `import { expect } from '@jest/globals';` to test files or configure Jest globals properly.Run `npm install --save-dev babel-jest-assertions` and ensure it's in `node_modules`.