开玩笑-当我在TS文件中使用SCSS导出的变量时测试失败

时间:2019-10-08 14:47:14

标签: typescript vue.js sass jestjs

这是我的情况:

我有一个SCSS文件,可导出JS / Ts文件的变量(请参阅:https://til.hashrocket.com/posts/sxbrscjuqu-share-scss-variables-with-javascript)。

我在我的TypeScript模块之一中使用它们。

使用Jest运行测试时,似乎在我的TS模块中,我从SCSS文件获取的变量为空,因此测试失败。

我认为可能需要使用Jest进行特殊配置,但我在文档中找不到任何内容。

这是我的用例的一个很小的例子。

// StyleExample.scss file
:export {
  width: 768
}

// MyModule.ts
import sizes from '../my-path/StyleExample.scss';

// sizes.width is empty when running Jest tests but works fine otherwise

0 个答案:

没有答案