Home Run postcss process multiple times with different settings
Reply: 0

Run postcss process multiple times with different settings

user1733 Published in March 20, 2018, 3:25 pm

I am trying to write a utility function for my tests for postcss plugins. I want to compare processed results with expected ones via jest.

My issue is that the postcss process returns the same result for different files.

let fs = require('fs');
let postcss = require('postcss');
let plugin = require('./');
let run = (testFile, options = {}, plugins = []) => {
    return new Promise((resolve, reject) => {
        let inputFile = `./tests/${testFile}`;
        let expectFile = inputFile.replace('.css', '.expected.css');
        let input = fs.readFileSync(inputFile).toString();
        let expect = fs.readFileSync(expectFile).toString();
            .process(input, Object.assign({
                from: inputFile,
                to: expectFile
            }, options))
            .then(result => {
            .catch(error => reject(error));

it('stacks css rules', () => run('stacking.css'));
it('import files', () => run('import.css'));

I essentially want to be able to check a processed stacking.css to a stacking.expected.css. And then the same thing with import.css and import.expected.css. But although the input files are different, postcss return the same result (always the first to be processed) both times.

Is there a way to do this?

I've tried without a promise, I've tried expect().resolves.toEqual() inside the function passed into it also tried postcss.process().css

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.348758 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO