0

In some frameworks, snippet code for mocha tests is auto-generated like this:

it('should return current day', () => {
  return wrapped.run({}).then((response) => {
    expect(response.statusCode).to.be.equal(200);
    // more tests
  });
});

Why is the return needed? What is accomplished by returning a value from a mocha test?

  • https://stackoverflow.com/a/52641542/2729605 – malarres Feb 10 '21 at 10:38
  • @malarres I don't completely understand the explanations in that post. So the test expects a resolved promise. Then why not simply use `await` and wait for the resolution yourself? why is the return value needed? – Eshel Bar Meir Feb 11 '21 at 12:04
  • according to the linked answer, you can do either one or the other. I guess you can choose – malarres Feb 11 '21 at 13:27

1 Answers1

0

According to this, the return value is obsolete when you use the async/await syntax.