Home

Awesome

ava-postcss-tester Build Status Coverage Status

Test your PostCSS plugin with AVA and this handy tool.

// test.js
import test from 'ava';
import PostcssTester from 'ava-postcss-tester';

const tester = new PostcssTester({
  postcss: require('postcss'),
  plugin: require('.')
});

test('test name', async t => {
  const input = `
    .class {
      size: 100px;
    }
  `;
  const output = `
    .class {
      width: 100px;
      height: 100px;
    }
  `;
  await tester.test(input, output, t);
});

Installation

$ npm install -D ava-postcss-tester

Usage

Create a new tester by calling new PostcssTester with an options object:

import test from 'ava';
import PostcssTester from 'ava-postcss-tester';

const tester = new PostcssTester({
  postcss: require('postcss'),
  plugin: require('.'),
  tolerateWarnings: true
});

Then you can run the async function `tester.test(input, output, t, options)``:

test('test name', async t => {
  const input = `
    .class {
      size: 100px;
    }
  `;
  const output = `
    .class {
      width: 100px;
      height: 100px;
    }
  `;
  await tester.test(input, output, t, {
    pluginOptions: {
      sizeShorthandActivated: true
    },
    pluginsAfter: [require('autoprefixer')]
  });
});

Related

License

This project is licensed under the MIT license.