How to use the jest-util.isPromise function in jest-util

To help you get started, we’ve selected a few jest-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / jest / packages / jest-circus / src / index.ts View on Github external
throw asyncError;
  }
  if (typeof blockFn !== 'function') {
    asyncError.message = `Invalid second argument, ${blockFn}. It must be a callback function.`;
    throw asyncError;
  }
  dispatch({
    asyncError,
    blockName,
    mode,
    name: 'start_describe_definition',
  });
  const describeReturn = blockFn();

  // TODO throw in Jest 25
  if (isPromise(describeReturn)) {
    console.log(
      formatExecError(
        new ErrorWithStack(
          chalk.yellow(
            'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
              'Returning a value from "describe" will fail the test in a future version of Jest.',
          ),
          describeFn,
        ),
        {rootDir: '', testMatch: []},
        {noStackTrace: false},
      ),
    );
  } else if (describeReturn !== undefined) {
    console.log(
      formatExecError(