🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

@csstools/pack-test

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/pack-test

Verify that the published contents of your node package will pass a basic smoke test.

npmnpm
Version
1.0.0
Version published
Weekly downloads
97
9600%
Maintainers
3
Weekly downloads
 
Created
Source

Pack Test

npm version Build Status

Verify that the published contents of your node package will pass a basic smoke test.
This tests creates a pack of your node modules just like npm publish and tries to import it.

Why do static analysis when you can brute force it?

API

Read the API docs

Usage

See test/_tape.mjs in the base plugin for a minimal example.

  • Install this package as a dev dependency.
npm install @csstools/pack-test --save-dev
  • Create a test directory in your project.

  • Write some CSS that will be processed by your plugin.

/* test/basic.css */
.foo {
	color: oklch(40% 0.268735435 34.568626);
}
  • Describe your test cases in a JavaScript file.
/* test/_tape.mjs */
import { postcssTape } from '@csstools/pack-test';
import plugin from '<your plugin package name>';

postcssTape(plugin)({
	basic: {
		message: "supports basic usage",
	},
	'basic:color': {
		message: "supports { color: '<a color>' }",
		options: {
			color: 'purple'
		}
	},
});
  • Run the tests.
# See https://nodejs.org/docs/latest/api/test.html for more usage details.
node --test
{
	"scripts": {
		"test": "node --test"
	}
}

Browse the source code and tests here or see tests in plugins for more usage details.

[!NOTE] We use test/_tape.mjs for our tests, but you can use any file name you want.
We like to group things in a test directory and we use a leading underscore to sort it before the css files.

File name format and test case naming

Test source files and test case names are related.
The test case name is expected to be the relative file path with the .css extension removed.

Test variants (with different plugin options) are separated by a colon :.

All test files are expected to be in a test directory in the current working directory.

test case namefile nameresult file namenotes
basictest/basic.csstest/basic.result.css
basic:colortest/basic.csstest/basic.color.result.cssA variant test for basic. Everything after : is ignored.
foo/bartest/foo/bar.csstest/foo/bar.result.cssA test file in a directory

.gitignore

We recommend adding *.result.css to your .gitignore file.
This is not functionally required, but it will reduce noise in your git history.

Quickly update all expect.css files.

Set env variable REWRITE_EXPECTS to true to update all expect.css files.

example :

{
	"scripts": {
		"test": "node --test",
		"test:rewrite-expects": "REWRITE_EXPECTS=true node --test"
	}
}

Keywords

node

FAQs

Package last updated on 03 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts