PostCSS Tape is a development utility designed to streamline the testing of PostCSS plugins. Currently at stable version 6.0.1, this package offers a focused approach to testing by abstracting the boilerplate often associated with PostCSS processing. It allows developers to define test cases efficiently through configuration files like `.tape.js`, `.mjs`, or `.cjs`, supporting both CommonJS and ES Modules for test definitions. Key differentiators include its automatic test generation for empty cases, comprehensive options for testing plugin behavior (including PostCSS plugin options, process options, warning counts, and error matching), and a simple CLI-first interface. The package typically updates in response to major PostCSS releases, ensuring compatibility with the latest versions. It provides a structured yet flexible framework for ensuring the correctness and stability of PostCSS transformations.
npm install postcss-tapeVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation, configuration via .tape.js, and running tests for a PostCSS plugin using the CLI.
Upgrade your Node.js environment to version 10 or higher (e.g., using `nvm install 16 && nvm use 16`).
Verify and update your `postcss` peer dependency in `package.json` to a compatible version (e.g., `"postcss": "^8.4.0"`).
If upgrading, verify that your test configuration file name and location align with the new resolution order. Consider renaming to `postcss-tape.config.js` for explicit recognition.
Either rename your config file to `.tape.mjs`, or add `"type": "module"` to your `package.json`. Alternatively, use CommonJS syntax (`module.exports = { ... }`) and a `.cjs` extension or a `.js` file without `"type": "module"`.Install PostCSS: `npm install postcss` or `yarn add postcss`.
Rename the configuration file to `.tape.mjs` or add `"type": "module"` to your project's `package.json`. Alternatively, switch to CommonJS `module.exports` syntax and use a `.cjs` extension or a `.js` file without `"type": "module"`.
Ensure a configuration file exists at the root of your project or specify its path using the `--config` option (e.g., `postcss-tape --config path/to/my-tests.js`). Double-check file name and extension.