小编And*_*ham的帖子

Jest 是否支持依赖任务?

如果之前的测试已经通过,是否可以只在 Jest 中运行测试?我在文档中找不到关于真实回调的任何内容。例如:

var array = [1, 2, 3, 4];

describe("Test task", () => {
  test("array length", () => {
    expect(array).toHaveLength(4);;
  });
  test("first item value", () => {
    expect(array[0]).toBe(1);;
  });
});
Run Code Online (Sandbox Code Playgroud)

一个简单的例子,但是如果“数组长度”测试已经通过,“第一个项目值”测试是否有可能运行,不仅仅是执行以下操作

var array = [1, 2, 3, 4];

describe("Test task", () => {
  test("array length", () => {
    expect(array).toHaveLength(4);;
  });
  if(array.length == 4){
    test("first item value", () => {
      expect(array[0]).toBe(1);
    });
  }
});
Run Code Online (Sandbox Code Playgroud)

javascript node.js jestjs

9
推荐指数
1
解决办法
1831
查看次数

标签 统计

javascript ×1

jestjs ×1

node.js ×1