theintern / intern

A next-generation code testing stack for JavaScript.
https://theintern.io/
Other
4.36k stars 309 forks source link

tdd and bdd interface types should disallow async suite declarations #1148

Closed jason0x43 closed 4 years ago

jason0x43 commented 4 years ago

tl;dr Intern's typings allow async functions to be used as suite factories, but they don't work. They probably shouldn't work since they'd break focused testing support (#514), so the typings should be fixed.

Currently a suite with an async callback will build, but it won't run:

describe('something', async () => {
  await Promise.resolve();

  test('should do something', () => {
     // ...
  });
});

When a suite like this is executed, Intern 4.x will fail:

TOTAL: tested 1 platforms, 0 passed, 0 failed
Unhandled rejection: Error: A test must be declared within a suite
  ...
(ノಠ益ಠ)ノ彡┻━┻
Error: A test must be declared within a suite
  ...

The typings should explicitly prevent async callbacks from being used in suite declarations.