小编gre*_*end的帖子

从测试中自动生成文档(javascript、jest)

我想生成依赖于测试的文档。例如,我有一个包含测试的文件:

describe("sum", () => {
  it("sums 1 and 2", () => {
    expect(sum(1, 2)).toEqual(3);
  });
  it("sums 3 and 4", () => {
    expect(sum(3, 4)).toEqual(7);
  });
});

describe("multiplication", () => {
  it("multiply 10 and 20", () => {
    expect(multiplication(10, 20)).toEqual(200);
  });
  it("multiply 30 and 40", () => {
    expect(multiplication(30, 40)).toEqual(1200);
  });
});

Run Code Online (Sandbox Code Playgroud)

并且取决于该文件,我希望收到类似此测试文件顶部的评论(摘要)的内容:

// Index test cases

// sum
// - [x] sums 1 and 2
// - [x] sums 3 and 4

// multiplication
// - [x] multiply 10 and …
Run Code Online (Sandbox Code Playgroud)

javascript testing documentation jestjs

7
推荐指数
0
解决办法
1138
查看次数

标签 统计

documentation ×1

javascript ×1

jestjs ×1

testing ×1