如何在Jest中循环动态测试用例?
我有以下测试用例如何使用it/test方法动态创建jest测试用例.
这是我尝试过的,但它只是通过而没有在循环中排除测试用例.
const mymodule = require('mymodule');
let testCases = [
{q: [2, 3],r: 5},
{q: [1, 2],r: 3},
{q: [7, 0],r: 7},
{q: [4, 4],r: 8}
];
describe("Test my Math module", () => {
test("test add sub module", () => {
for (let i = 0; i < testCases.length; i++) {
let item = testCases[i];
let q = item.q;
let expected = item.r;
it(`should add ${q[0]},${q[1]} to ${expected}`, () => {
let actual = mymodule.add(q[0] + …Run Code Online (Sandbox Code Playgroud)