stylelint-jest-rule-tester
TypeScript icon, indicating that this package has built-in type declarations

2.1.7 • Public • Published

Stylelint Jest Rule Tester

This is not an official stylelint package.

tests

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,
        },
    ],
});

Package Sidebar

Install

npm i stylelint-jest-rule-tester

Weekly Downloads

195

Version

2.1.7

License

MIT

Unpacked Size

10.2 kB

Total Files

5

Last publish

Collaborators

  • electrovir