jest-transform-css icon indicating copy to clipboard operation
jest-transform-css copied to clipboard

transform not working for windows

Open VikasAgarwal1984 opened this issue 4 years ago • 2 comments

Sample Code: https://github.com/VikasAgarwal1984/package-deploy-learn/tree/0.0.1

Issue: Transform not working

Jest config file path https://github.com/VikasAgarwal1984/package-deploy-learn/blob/0.0.1/jest.config.js

To understand what is failing, i updated the index file in node_modules to the content copied in below link: https://github.com/VikasAgarwal1984/package-deploy-learn/blob/0.0.1/dev/index.js

I think the issue is require("${postcssRunner}")(

does not work as everything is Stringified, and ${} flat the '' in windows. so when code gets evaluated it fails. To double check, i debugged with following paths:


// works
    // const postcssRunner = 'D:\\\\git\\\\package-deploy-learn\\\\node_modules\\\\jest-transform-css\\\\postcss-runner.js';
    //const postcssRunner = 'D:/git/package-deploy-learn/node_modules/jest-transform-css/postcss-runner.js';

    // does not work
    const postcssRunner = `${__dirname}/postcss-runner.js`;
    //const postcssRunner = p.normalize(`${__dirname}/postcss-runner.js`);
    //const postcssRunner = 'D:\\git\\package-deploy-learn\\node_modules\\jest-transform-css\\postcss-runner.js';
    //const postcssRunner = 'D:\\git\\package-deploy-learn\\node_modules\\jest-transform-css/postcss-runner.js';


\\\\ gets translate to \\ in  require("${postcssRunner}") and path works.

I tested above Repository in Ubuntu VM, there was no issue, and npm run test works fine. Any insights?

VikasAgarwal1984 avatar Apr 03 '22 19:04 VikasAgarwal1984

Thanks for your nice report! Maybe using path.join could work?

So something like const postcssRunner = path.join(__dirname, "postcss-runner.js") could do the trick?

dferber90 avatar Apr 04 '22 12:04 dferber90

I think issue is with below line:

File: https://github.com/dferber90/jest-transform-css/blob/master/index.js

Line No: 71 require("${postcssRunner}")(

We need to preserve'\\', Something like below should work I believe. https://stackblitz.com/edit/web-platform-zoctv4?file=script.js

VikasAgarwal1984 avatar Apr 04 '22 13:04 VikasAgarwal1984