Registry / testing / rollup-plugin-power-assert

rollup-plugin-power-assert

JSON →
library0.2.0jsnpmunverified

Rollup and Vite plugin for power-assert, providing descriptive assertion messages through the standard Node.js assert interface. Current stable version is 0.2.0. It transforms assertion expressions (e.g., assert(ary.indexOf(zero) === two)) into detailed, labeled output showing intermediate values. The library supports both Rollup and Vite/Vitest with minimal configuration, and is part of the power-assert monorepo. Key differentiators include zero API overhead and compatibility with Vitest's assert API.

npm install rollup-plugin-power-assert
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-POWE
R
rollup-plugin-power-assert
testingjavascriptv0.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

powerAssert
✓ import { powerAssert } from 'rollup-plugin-power-assert'
✗ import powerAssert from 'rollup-plugin-power-assert'
Must use named import; default import is not available.
powerAssert (CommonJS)
✓ const { powerAssert } = require('rollup-plugin-power-assert')
✗ const powerAssert = require('rollup-plugin-power-assert')
CommonJS requires destructuring; the module exports an object with named exports.
type definition
✓ import type { PowerAssertOptions } from 'rollup-plugin-power-assert'
TypeScript types are included; use named type import for configuration options.

Configure Vite/Vitest with the powerAssert plugin to enable descriptive assertion messages in test files.

import { defineConfig } from 'vite'; import { powerAssert } from 'rollup-plugin-power-assert'; const testPattern = 'examples/**/__tests__/**/*.test.mts'; export default defineConfig({ plugins: [ powerAssert({ include: testPattern, }), ], test: { include: testPattern, }, });
Debug
Known issues
gotchaThe plugin transforms assert() calls only; it does not transform other assertion libraries like chai or expect.
fix
Use Node.js assert module or Vitest's assert API. For other libraries, consider alternative power-assert wrappers.
affects: >=0.1.0
gotchaThe plugin requires the @power-assert/runtime package as a peer dependency. Failing to install it can result in runtime errors.
fix
Install the peer dependency: npm install --save-dev @power-assert/runtime
affects: >=0.2.0
deprecatedThe plugin may be deprecated in future versions of power-assert monorepo; check for migration notes.
fix
Monitor the repository for deprecation notices and plan migration to alternative assertion enhancement tools.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module '@power-assert/runtime'
Missing peer dependency @power-assert/runtime
fix
npm install --save-dev @power-assert/runtime
TypeError: (0 , _rollupPluginPowerAssert.powerAssert) is not a function
Using default import instead of named import
fix
Change to: import { powerAssert } from 'rollup-plugin-power-assert'
AssertionError: assert(...) expression not transformed
The file is not included in the plugin's include pattern
fix
Ensure the file path matches the include glob pattern in the plugin options.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
@power-assert/runtimerequiredrequired peer dependency for runtime assertion enhancement
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
rollup-plugin-power-assert — npm install rollup-plugin-power-assert · libregistry