remix-run/remix · error · TypeError

ERR_INVALID_ARG_VALUE

ERR_INVALID_ARG_VALUE

Error message

The argument 'error' may not be an empty object. Received ${stringify(expectedError)}

What it means

When assert.throws/rejects matches errors against a plain-object expectation, the object must have at least one key; an empty object {} is meaningless as a matcher and throws ERR_INVALID_ARG_VALUE before the assertion runs.

Source

Thrown at packages/assert/src/lib/assert.ts:198

function validateExpectedDoesNotError(expectedError: unknown): void {
  if (
    expectedError == null ||
    typeof expectedError === 'function' ||
    expectedError instanceof RegExp
  ) {
    return
  }

  throw createInvalidArgumentTypeError(
    'expected',
    'of type function or an instance of RegExp',
    expectedError,
  )
}

function validateExpectedObject(expectedError: object): void {
  if (Object.keys(expectedError).length === 0) {
    throw createInvalidArgumentValueError(
      'error',
      `may not be an empty object. Received ${stringify(expectedError)}`,
    )
  }
}

function getMissingExceptionMessage(
  operator: 'throws' | 'rejects',
  expectedError: unknown,
  message: AssertionMessage | undefined,
): string {
  let expectedName = getExpectedErrorName(expectedError)
  let kind = operator === 'throws' ? 'exception' : 'rejection'
  let base =
    expectedName === undefined
      ? `Missing expected ${kind}`
      : `Missing expected ${kind} (${expectedName})`

View on GitHub (pinned to 9696913134)

Solutions

  1. Add at least one property to match on: { name: 'TypeError' } or { message: '...' }
  2. Remove the object and assert on the class or message RegExp instead

Example fix

// before
assert.throws(() => f(), {})
// after
assert.throws(() => f(), { name: 'RangeError' })
Defensive patterns

Strategy: validation

Validate before calling

if (typeof expected === 'object' && Object.keys(expected).length === 0) throw new Error('empty expectation')

Prevention

When it happens

Trigger: Passing {} as the expected error: assert.throws(fn, {}).

Common situations: Programmatically building expectation objects where a lookup returns empty, or leftover placeholder {} from refactoring tests.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/c8017c73f874162d. Report an issue: GitHub.