にジャスミンのテスト中に不明なエラーがスローされていないがあるのでライブラリは、私は、以下の機能を持っているノードのjs
it('test if writing fails ', function() {
var writer = new Writer(
'/data/configurations/ab/ba/abba/test.json',
'content'
);
expect(function() {
writer.process()
}).toThrowError("Something went wrong during writing");
})
は、だからこれは失敗することが予想されます書き込むファイル。次に、ライブラリFSがキャッチされていないErrorをスローしています。ここ
はテストから出力されます。
Started
.....F
Failures:
1) writer test test if writing fails
Message:
Expected function to throw an Error.
Stack:
Error: Expected function to throw an Error.
at Object.<anonymous> (/vagrant/project/tests/utils/file/writerTest.js:42:6)
6 specs, 1 failure
Finished in 0.198 seconds
/vagrant/project/node_modules/mock-fs/lib/binding.js:1060
throw new FSError('ENOENT', filepath);
Error: ENOENT, no such file or directory '/vagrant/project/node_modules/jasmine/node_modules/exit'
at Binding.<anonymous> (/vagrant/project/node_modules/mock-fs/lib/binding.js:1060:13)
ので、ライブラリが投げるとエラーとtoThrowErrorはそれを得ることはありませんされています。誰かがそれを解決する方法や私の間違いを知っていますか?
ですから、投げられたエラーは期待されるエラーではありません。つまり、 'function(error){'は今まで呼ばれていませんでした。代わりに '.toThrow()'を使って何か違いはありますか? –