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
- Add at least one property to match on: { name: 'TypeError' } or { message: '...' }
- 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
- Always include at least one property (name, code, message) in object expectations
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
- ERR_INVALID_ARG_TYPE
- hmr must create a channel with a close function
- hmr must create a channel with an onFileEvents function
- hmr must create a channel with an updateWatchedFiles functio
- basePath must be a string
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/c8017c73f874162d.
Report an issue: GitHub.