微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

fast-check

编程之家收集整理的这个编程导航主要介绍了fast-check编程之家,现在分享给大家,也给大家做个参考。

fast-check 介绍

使用TypeScript编写的基于JavaScript的基于属性的测试框架(如QuickCheck) ,基于属性的测试框架检查属性的真实性。属性是这样的语句:对于所有(x,y,...),例如precondition(x,y,...)都认为property(x,y,...)为true。

通过以下方式安装模块:

yarn add fast-check --dev或npm install fast-check --save-dev

示例 :

const fc = require('fast-check');

// Code under test

const contains = (text,pattern) => text.indexOf(pattern) >= 0;

// Properties

describe('properties',() => {

// string text always contains itself

it('should always contain itself',() => {

fc.assert(fc.property(fc.string(),text => contains(text,text)));

});

// string a + b + c always contains b,whatever the values of a,b and c

it('should always contain its substrings',fc.string(),(a,b,c) => {

// Alternatively: no return statement and direct usage of expect or assert

return contains(a+b+c,b));

});

});

});

GitHub:https://github.com/dubzzz/fast-check

网站描述:用TypeScript编写基于Property 的JavaScript测试框架

fast-check

官方网站:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。