stylelint-jest-rule-tester
v2.1.7
Published
Simple stylelint.io rule tester that uses Jest.
Maintainers
Readme
Stylelint Jest Rule Tester
This is not an official stylelint package.
Simple function written in TypeScript to test custom stylelint plugin rules.
Largely influenced by jest-preset-stylelint/getTestRule.js.
Usage
This is from this project's test file.
import {testRule} from 'stylelint-jest-rule-tester';
import {visibilityRule} from './visibility.rule';
testRule({
// replace this name with your rule's name
ruleName: visibilityRule.ruleName,
description: 'should work primary option in array',
ruleOptions: [true],
// a plugin must be supplied so that stylelint can find the rule you want to test
linterOptions: {config: {plugins: ['./dist/test/plugins.js']}},
fix: true,
accept: [
{
code: 'a { color: pink; }',
},
],
reject: [
{
code: 'a { color: pink; visibility: hidden; }',
fixed: 'a { color: pink; }',
message: visibilityRule.message,
},
],
});