我怎样才能在单元测试中每次都收到新的电子邮件和 phone 号码?

How could I get new email and phone number everytime on unit test?

我正在为一个 public API 请求注册端点构建一个单元测试,而不是我的。

我正在与 chai 合作,这是一段代码:

it('should return register information', function(done) {
  let data = {
    User: {
      Name: 'test',
      Email: 'test@test.com',
      CellPhone: '666777888',
      Password: '123456789'
    }
  };

  testApi.register(data).then(res => { ... });

也许有图书馆?

尝试facker

const faker = require('facker');
it('should return register information', function(done) {
  let data = {
    User: {
      Name: faker.name.findName(),
      Email: faker.internet.email(),
      CellPhone: faker.phone.phoneNumber(),
      Password: '123456789'
    }
  };

  testApi.register(data).then(res => { ... });