Node.js 18 の node:test の型

4012 ワード

@types/node にまだなさそうだから

declare module "node:test" {
  type TestContext = {
    diagnostic(message: string): void;
    runOnly(shouldRunOnlyTests: boolean): void;
    skip(...message: string[]): void;
    todo(...message: string[]): void;
    test: Test;
  };
  type TestCb =
    | ((testContext: TestContext) => void)
    | ((testContext: TestContext) => Promise<void>);
  type Test = (name: string, cb: TestCb) => void;
  const test: Test;
  export default test;
}