text: // 使用 mock 函数
  function forEach(items, callback) {
    for (let index = 0; index < items.length; index++) {
      callback(items[index]);
    }
  }
  test("mock function", () => {
    const mockCallback = jest.fn((x) => 42 + x);
    forEach([0, 1], mockCallback);
  
    // 此 mock 函数被调用了两次
    expect(mockCallback.mock.calls.length).toBe(2);
  
    // 第一次调用函数时的第一个参数是 0
    expect(mockCallback.mock.calls[0][0]).toBe(0);
  
    // 第二次调用函数时的第一个参数是 1
    expect(mockCallback.mock.calls[1][0]).toBe(1);
  
    // 第一次函数调用的返回值是 42
    expect(mockCallback.mock.results[0].value).toBe(42);
  });
  
  // .mock 属性
  
  // 模拟模块
  
  // users.test.js
  import axios from "axios";
  import Users from "./users";
  
  jest.mock("axios");
  
  test("should fetch users", () => {
    const users = [{ name: "Bob" }];
    const resp = { data: users };
    axios.get.mockResolvedValue(resp);
  
    // or you could use the following depending on your use case:
    // axios.get.mockImplementation(() => Promise.resolve(resp))
  
    return Users.all().then((data) => expect(data).toEqual(users));
  });
  
  // Mock 实现
  