CSSでネストされたインポートステートメントをサポートするPostCSSプラグインを作成しています。このユニットテストでは、テストの失敗で、その結果、期待:PostCSSプラグインのJestユニットテストで同等性をテストする適切な方法
FAIL ./index.test.js
replaces @import with the contents of the file being imported.
expect(received).toEqual(expected)
Expected value to equal:
".vendor { background: silver; }"
Received:
".vendor {
background: silver
}"
:中
.vendor { background: silver; }
結果:
var postcss = require('postcss');
var plugin = require('./');
function run(input, output, opts) {
return postcss([ plugin(opts) ]).process(input)
.then(result => {
expect(result.css).toEqual(output);
expect(result.warnings().length).toBe(0);
});
}
it('replaces @import with the contents of the file being imported.',() => {
return run('@import "./vendor.css";',
".vendor { background: silver; }");
});
./vendor.css
は次のようになります
ここにプラグインコードがあります:https://github.com/eriklharper/postcss-nested-import/blob/master/index.js#L36-L57
私は間違っていると思いますか? PostCSSやJest、あるいはその両方の問題であるかどうかはわかりません。