jestjs/jest · error · Error

describe does not expect any arguments

Error message

describe does not expect any arguments

What it means

A describe() callback must declare zero parameters. Env.ts:409-411 throws when specDefinitions.length > 0 (the function's declared arity), because Jasmine does not pass any argument to the describe body and a parameter suggests the author expects injection that never happens — a likely bug.

Source

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

      };

      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 f49721c78e)

Solutions

  1. Remove the parameter from the describe callback: describe('name', () => {...}).
  2. If you need async behavior, put it inside an it/beforeAll with a done argument or use async functions there — describe bodies must be synchronous and parameterless.

Example fix

// before — describe callback declares a param
describe('api', (done) => { it('works', () => {}); });

// after — parameterless describe
describe('api', () => {
  beforeAll((done) => { setup(done); });
  it('works', () => {});
});
Defensive patterns

Strategy: validation

Validate before calling

function assertDescribeArity(fn: Function) {
  if (fn.length > 0) throw new Error('describe callback must take no arguments');
}

Type guard

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

Prevention

When it happens

Trigger: Writing `describe('name', (done) => {...})` or `describe('name', function(ctx){...})`. Function .length is the number of declared params before defaults; >0 triggers the throw at line 410.

Common situations: Confusing describe with it (which can take a done callback); refactoring an async test into a suite but leaving the done parameter; using an arrow that declares an unused param.

Related errors


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/2a2fe324c9a899fd.json. Report an issue: GitHub.