如何使crypto.randomBytes导致错误

时间:2016-07-27 15:10:20

标签: node.js testing mocha

< !doctype html >
    <
    html lang = "en" >
    <
    head >
    <
    meta charset = "utf-8" >
    <
    meta name = "viewport"
content = "width=device-width, initial-scale=1" >
    <
    link rel = "stylesheet"
href = "https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css" >
    <
    title > React App < /title> <
    /head> <
    body >
    <
    div id = "root" > < /div>
    <
    script src = "bundle.js" > < /script> <
    /body> <
    /html>

我需要创建一个err为true的测试代码。如何让crypto.randomByte导致错误。

1 个答案:

答案 0 :(得分:1)

如果您提供的值无效,则会出错。例如

crypto.randomBytes(-1)