Open romaricpascal opened 2 years ago
@romaricpascal Interesting idea! While I'm a bit hesitant seeing that node's require.extensions
is officially deprecated, it does seem like this would be useful -- and other projects are still using similar workarounds. I might lean toward using something like pirates instead of the require.extensions
API directly.
I probably won't get to this for awhile, but I'd be open to reviewing a PR that adds this functionality to True. Feel free to base it off of the v6.1.0 release.
@mirisuzanne What do you think of this idea?
@jgerigmeyer This is outside my expertise, so I'm not sure what the tradeoffs are. Feel free to handle the JS API in whatever ways make sense to you. :)
It's be great if the
sass-true
package was providing a way to register the.scss
into Node'srequire.exensions
. It'd allow test tools like Mocha (Jasmine too) to requirescss
files directly, compiling them on the fly into a bit of JavaScript running sass-true.This is what I have working for
sass-true
6.1, but looking at the current main branch, I believe it'll need some adjustments:Then the following
.mocharc.js
file allows Mocha to load the SCSS files:It'd work for Jasmine too with:
And I think the
toTestScript
function could be used for making a Jest transform.The
runner
function is only necessary for two things: importingtrue
in the files automatically and configuring the terminal output. My example is obviously opinionated, but if sass-true were to provide these as options forrunSass
that'd save the need for thatrunner
function altogether.It'd be great if the
register
file was provided directly by thesass-true
package (a la@babel/register
), but maybe documentation may be enough too.