{"id":13798,"library":"postcss-tape","title":"PostCSS Tape","description":"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.","status":"active","version":"6.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/csstools/postcss-tape","tags":["javascript","postcss","css","postcss-plugin","testing","tests","tools","tape"],"install":[{"cmd":"npm install postcss-tape","lang":"bash","label":"npm"},{"cmd":"yarn add postcss-tape","lang":"bash","label":"yarn"},{"cmd":"pnpm add postcss-tape","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for processing CSS and running PostCSS plugins during tests.","package":"postcss","optional":false}],"imports":[{"note":"Test configurations are defined by exporting a default object from a dedicated configuration file (.tape.js, .tape.mjs, etc.). Use ESM `export default` for `.mjs` files or `.js` files when `type: 'module'` is set in `package.json`.","wrong":"module.exports = { 'my-test': { message: '...' } }; // In .mjs file","symbol":"Configuration object (ESM)","correct":"export default { 'my-test': { message: '...' } }; // In .tape.mjs or .tape.js with type: 'module'"},{"note":"Test configurations can also be defined using CommonJS `module.exports` for `.cjs` files or `.js` files when `type: 'module'` is not explicitly set in `package.json`.","wrong":"export default { 'my-test': { message: '...' } }; // In .cjs file","symbol":"Configuration object (CJS)","correct":"module.exports = { 'my-test': { message: '...' } }; // In .tape.cjs or .tape.js without type: 'module'"},{"note":"The `postcss-tape` package is primarily a command-line interface (CLI) tool. It is not designed for direct programmatic import as a JavaScript module. The recommended way to use it is via `package.json` scripts or by directly executing the `postcss-tape` command.","wrong":"import postcssTape from 'postcss-tape'; // or require('postcss-tape')","symbol":"postcss-tape CLI runner","correct":"npm test // if 'postcss-tape' is in package.json scripts"}],"quickstart":{"code":"npm install --save-dev postcss-tape\n# Add to your package.json\n# {\n#   \"scripts\": {\n#     \"test\": \"postcss-tape\"\n#   }\n# }\n# Create a file named .tape.js at the root of your project\n// .tape.js\nexport default {\n  'basic-test': {\n    message: 'supports basic plugin functionality',\n    source: 'input.css',\n    expect: 'output.expect.css',\n    options: { /* plugin options */ }\n  },\n  'another-test:variant': {\n    message: 'supports a variant of another test',\n    source: 'input.css',\n    expect: 'output-variant.expect.css',\n    options: { /* different plugin options */ }\n  }\n};\n// Optional: Create input.css and output.expect.css in a 'fixtures' directory\n// Then run:\nnpm test","lang":"javascript","description":"Demonstrates installation, configuration via .tape.js, and running tests for a PostCSS plugin using the CLI."},"warnings":[{"fix":"Upgrade your Node.js environment to version 10 or higher (e.g., using `nvm install 16 && nvm use 16`).","message":"Version 6.0.0 and above requires Node.js version 10 or greater. Older Node.js environments will result in errors.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Verify and update your `postcss` peer dependency in `package.json` to a compatible version (e.g., `\"postcss\": \"^8.4.0\"`).","message":"PostCSS Tape v6.0.0 introduced support for PostCSS 7 and 8 concurrently. Ensure your `postcss` peer dependency is within the `^7 || ^8` range. Older `postcss-tape` versions might have different PostCSS peer dependency requirements.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"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.","message":"The order of configuration file resolution changed in v6.0.0. Configuration files are now resolved in the order: `postcss-tape.config.js`, `postcss-tape.config.mjs`, `postcss-tape.config.cjs`, `.tape.js`, `.tape.mjs`, and `.tape.cjs`.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"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\"`.","message":"When using `export default` in `.tape.js` (an ES Module syntax), ensure your Node.js project is configured for ESM (e.g., by adding `\"type\": \"module\"` to `package.json`) or use a `.mjs` extension. Otherwise, you might encounter `SyntaxError: Cannot use import statement outside a module`.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'6.0.1':21 'abstract':31 'allow':40 'approach':27 'associ':35 'automat':68 'behavior':79 'boilerpl':33 'case':45,73 'cjs':54 'cli':95 'cli-first':94 'commonj':57 'compat':109 'comprehens':74 'configur':48 'correct':124 'count':87 'css':132 'current':17 'defin':43 'definit':63 'design':9 'develop':7,41 'differenti':65 'effici':46 'empti':72 'ensur':108,122 'error':89 'es':59 'file':49 'first':96 'flexibl':119 'focus':26 'framework':120 'generat':70 'includ':66,80 'interfac':97 'javascript':130 'key':64 'latest':112 'like':50 'major':105 'match':90 'mjs':52 'modul':60 'offer':24 'often':34 'option':75,83,85 'packag':23,99 'plugin':16,78,82,135 'postcss':1,3,15,37,81,106,128,131,134 'postcss-plugin':133 'process':38,84 'provid':115 'releas':107 'respons':103 'simpl':93 'stabil':126 'stabl':19 'streamlin':11 'structur':117 'support':55 'tape':2,4,139 'tape.js':51 'test':13,29,44,62,69,77,136,137 'tool':138 'transform':129 'typic':100 'updat':101 'util':8 'version':20,113 'warn':86 'yet':118","created_at":"2026-04-20T01:56:22.059002+00:00","updated_at":"2026-04-20T01:56:22.059002+00:00","problems":[{"fix":"Install PostCSS: `npm install postcss` or `yarn add postcss`.","cause":"The required `postcss` peer dependency is not installed in the project.","error":"Error: Cannot find module 'postcss'"},{"fix":"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\"`.","cause":"An ES Module (`import`/`export`) syntax is used in a configuration file (`.tape.js`) that is being interpreted as a CommonJS module.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"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.","cause":"The `postcss-tape` runner could not locate a valid configuration file (e.g., `.tape.js`, `postcss-tape.config.js`) in the expected locations.","error":"Error: Test suite failed to run: No test configuration file found."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"tape","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/csstools/postcss-tape","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/postcss-tape","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}