Jest で async 関数のエラーを検証する
1184 ワード
環境
- Jest: 26.1.0
- Typescript: 3.9.7
検証したい関数
const fail = async () => {
throw new Error();
}
テスト
await expect(fail).rejects.toThrowError(Error);
参考
const fail = async () => {
throw new Error();
}
テスト
await expect(fail).rejects.toThrowError(Error);
参考
await expect(fail).rejects.toThrowError(Error);
Author And Source
この問題について(Jest で async 関数のエラーを検証する), 我々は、より多くの情報をここで見つけました https://qiita.com/tktcorporation/items/d9dc74ca9c02e84db798著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .