-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SASS fails to compile files under Jest #1692
Comments
I have the same problem in my environment, if I run |
Duplicate of #710. |
@jathak If deprecated, the explanation in #710 is not sufficient. Either #710 or the "recommended method" resolves the error, or should explicitly state in the README or API reference that execution by Jest is not supported. |
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
We also had this issue, and also found that setting the Jest environment to "node" did not help. However, we found another workaround, Instead, what did work is using the legacy API. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the
(this bit us a few times 😅 ) |
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
There is a bug where `sass.compile` will throw with an extremely unhelpful error trace when running in Jest [[1]]. > TypeError: J.getInterceptor$ax(...).map$1$1 is not a function > > at Object.map$1$1$ax (node_modules/sass/sass.dart.js:24513:44) > at listDir_closure0.call$0 (node_modules/sass/sass.dart.js:87066:18) > at Object._systemErrorToFileSystemException0 (node_modules/sass/sass.dart.js:20776:23) > at Object.listDir0 (node_modules/sass/sass.dart.js:20771:16) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84710:34) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) > at _realCasePath_helper_closure0.call$0 (node_modules/sass/sass.dart.js:84706:35) > at JsLinkedHashMap.putIfAbsent$2 (node_modules/sass/sass.dart.js:27273:24) > at _realCasePath_helper0.call$1 (node_modules/sass/sass.dart.js:84699:32) It has been suggested that it is related to `path.absolute` being overridden by the jsdom environment [[2]], but the workaround of using the "node" environment does not solve the issue for us. Instead, what did work is using the legacy API [[3]]. I'm not sure why this is, but it seems to do the trick. Note that with the legacy API, the file path is part of the options object, rather than being the first argument. If you forget to change the call signature, you will get a different unhelpful error message: > NoSuchMethodError: method not found: 'call' [1]: sass/dart-sass#1692 [2]: sass/dart-sass#710 (comment) [3]: https://sass-lang.com/documentation/js-api#legacy-api
@akabekobeko @lfdebrux Does setting |
@jathak Add npm
Configmodule.exports = {
testEnvironment: 'jest-environment-node-single-context',
verbose: true,
testTimeout: 10000,
transform: {
'^.+\\.ts$': 'ts-jest',
},
}; Test on Jest
import { transpileCss } from './css';
it('Transpile SCSS', () => {
const css = transpileCss('sass', './src2/data/scss/app.scss');
const expected = `body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #fbfcfa;
}`;
expect(css).toBe(expected);
}); Result
|
I tried to use it, but fails with:
Could it be because I'm using Yarn with pnp modules? Reported in kayahr/jest-environment-node-single-context#10 |
@TheLonelyAdventurer |
@akabekobeko yeah it's probably a specific issue with Yarn |
I found another workaround. This method also works for Here is the tricks:
The following PR is an actual successful example. |
Update: the package also fails with yarn1 and NPM. I guess there is an issue with node modules. |
Running
sass.compile(path)
wil throw a suspicious exception:The code above was run using
jest
.Basic code that reproduces the error:
The exact same code works when run outside jest.
I've tracked down the compiled js of sass up to this line of sass.dart.js:
which is called by:
which is in turn called by:
As expected these are the results in my debugger for checking the parameters:
I am not sure what
map$1$1
is, but it seems to depend on the running environment as far as I understand the problem.The text was updated successfully, but these errors were encountered: