jestjs/jest · error · Error

describe does not expect any arguments

Error message

describe does not expect any arguments

What it means

Jasmine's describe callback must declare ZERO parameters — it is invoked synchronously with no arguments (`specDefinitions.call(suite)`). If the callback function has a declared parameter (`.length > 0`), Env.describe throws this Error at Env.ts:411, because passing a function that expects arguments indicates the user misunderstands the API (likely confusing it with a spec's done callback).

Solutions

  1. Remove the parameter from the describe callback: `describe('x', () => { ... })`.
  2. If you need async setup, put it inside `beforeAll(async () => {...})` or use the `done` callback inside `it(...)` instead.

Example fix

// before
describe('my suite', (done) => {
  // done is never called by jasmine for describe
});
// after
describe('my suite', () => {
  beforeAll(async () => { await setup(); });
});
Defensive patterns

Strategy: validation

Validate before calling

// Enforce zero-arity describe callbacks in a wrapper.
function strictDescribe(name: string, fn: () => void) {
  if (fn.length > 0) {
    throw new Error(`describe('${name}') callback must take no arguments (got arity ${fn.length}).`);
  }
  return describe(name, fn);
}

Type guard

function isZeroArityFn(fn: Function): boolean {
  return fn.length === 0;
}

Prevention

When it happens

Trigger: Writing `describe('x', (done) => { ... })` or `describe('x', function(done) { ... })`. The check at Env.ts:410 reads `specDefinitions.length > 0` (function arity).

Common situations: Confusing describe's signature with `it(name, (done) => {...})` which DOES support a done callback for async tests; copy-paste of an async spec callback into a describe; migration from another framework where suite callbacks receive context.

Related errors


AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10). Data as JSON: /api/errors/2a2fe324c9a899fd. Report an issue: GitHub.

Appendix: source

Thrown at packages/jest-jasmine2/src/jasmine/Env.ts:411

      };

      this.describe = function (
        description: Circus.TestNameLike,
        specDefinitions,
      ) {
        const suite = suiteFactory(description);
        if (specDefinitions === undefined) {
          throw new Error(
            'Missing second argument. It must be a callback function.',
          );
        }
        if (typeof specDefinitions !== 'function') {
          throw new TypeError(
            `Invalid second argument, ${specDefinitions}. It must be a callback function.`,
          );
        }
        if (specDefinitions.length > 0) {
          throw new Error('describe does not expect any arguments');
        }
        if (currentDeclarationSuite.markedPending) {
          suite.pend();
        }
        if (currentDeclarationSuite.markedTodo) {
          // @ts-expect-error TODO Possible error: Suite does not have todo method
          suite.todo();
        }
        addSpecsToSuite(suite, specDefinitions);
        return suite;
      };

      this.xdescribe = function (description, specDefinitions) {
        const suite = suiteFactory(description);
        suite.pend();
        addSpecsToSuite(suite, specDefinitions);
        return suite;
      };

View on GitHub (pinned to 8e6d128e4a)