jestjs/jest · error · Error

Expect takes at most one argument.

Error message

Expect takes at most one argument.

What it means

expect() accepts exactly one argument — the actual value under test. Passing extra arguments throws an Error because there is no defined meaning for them and it almost always indicates a typo (e.g. expecting `expect(a).toBe(b)` but writing `expect(a, b).toBe()`). The check keeps assertions unambiguous.

Solutions

  1. Use the matcher chain: `expect(actual).toEqual(expected)` instead of `expect(actual, expected)`.
  2. Remove any extra arguments to expect() so only the actual value is passed.
  3. If you intended to pass options, check the matcher API — options go on the matcher, not on expect().

Example fix

// before
expect(result, expected).toBeTruthy(); // two args

// after
expect(result).toEqual(expected);
Defensive patterns

Strategy: validation

Validate before calling

// Wrap expect in dev/test helpers to surface misuse at the call site.
function expectOne(actual) {
  if (arguments.length > 1) {
    throw new Error('expect() takes one argument; use a matcher for the comparison.');
  }
  return expect(actual);
}

Prevention

When it happens

Trigger: Calling `expect(value, extra)` with more than one argument. Most often a misplaced matcher: `expect(a, b)` instead of `expect(a).toEqual(b)`, or a stray comma/comma operator.

Common situations: Confusing expect's signature with chai-style `assert.equal(a, b)`; copy-paste errors; an extra argument slipped in by a refactor.

Related errors


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

Appendix: source

Thrown at packages/expect/src/index.ts:107

  };
};

const getPromiseMatcher = (name: string, matcher: RawMatcherFn) => {
  if (name === 'toThrow') {
    return createThrowMatcher(name, true);
  } else if (
    name === 'toThrowErrorMatchingSnapshot' ||
    name === 'toThrowErrorMatchingInlineSnapshot'
  ) {
    return createToThrowErrorMatchingSnapshotMatcher(matcher);
  }

  return null;
};

export const expect: Expect = (actual: any, ...rest: Array<any>) => {
  if (rest.length > 0) {
    throw new Error('Expect takes at most one argument.');
  }

  const allMatchers = getMatchers();
  const expectation: any = {
    not: {},
    rejects: {not: {}},
    resolves: {not: {}},
  };

  const err = new JestAssertionError();

  for (const name of Object.keys(allMatchers)) {
    const matcher = allMatchers[name];
    const promiseMatcher = getPromiseMatcher(name, matcher) || matcher;
    expectation[name] = makeThrowingMatcher(matcher, false, '', actual);
    expectation.not[name] = makeThrowingMatcher(matcher, true, '', actual);

    expectation.resolves[name] = makeResolveMatcher(

View on GitHub (pinned to 8e6d128e4a)