remix-run/remix · error · AssertionError

expect(received).toThrow() requires a function (got ${typeof

Error message

expect(received).toThrow() requires a function (got ${typeof received})

What it means

A `remix.json` was found and loaded, but it has no `db` key, so `config.db === undefined` and the db command has no adapter/connection/migrations settings to work with. The message includes the resolved config path so you know exactly which file to edit.

Source

Thrown at packages/assert/src/lib/expect.ts:377

        () =>
          arguments.length < 2
            ? `${stringify(received)} to have property "${key}"`
            : `${stringify(received)} to have property "${key}" with value ${stringify(value)}`,
        value,
        'toHaveProperty',
      )
    },
    toMatchObject(expected) {
      check(
        matchesPartial(received, expected),
        () => `${stringify(received)} to recursively match ${stringify(expected)}`,
        expected,
        'toMatchObject',
      )
    },
    toThrow(expected) {
      if (typeof received !== 'function') {
        throw new AssertionError({
          message: `expect(received).toThrow() requires a function (got ${typeof received})`,
          operator: 'toThrow',
        })
      }
      let thrown = false
      let error: unknown
      try {
        ;(received as () => unknown)()
      } catch (e) {
        thrown = true
        error = e
      }
      let pass = thrown && checkErrorMatch(error, expected)
      check(
        pass,
        () =>
          thrown
            ? `error to be ${describeExpectedError(expected)}, got ${stringify(error)}`

View on GitHub (pinned to 9696913134)

Solutions

  1. Add a top-level `db` block: `{ "db": { "adapter": "sqlite", ... } }`
  2. Check JSON nesting — `db` must be a top-level key
  3. Validate remix.json with a JSON linter to catch dropped sections

Example fix

// before
{ "name": "my-app" }
// after
{
  "name": "my-app",
  "db": {
    "adapter": "sqlite",
    "filename": { "env": "DATABASE_FILE", "default": "data.db" }
  }
}
Defensive patterns

Strategy: type-guard

Validate before calling

import fs from 'node:fs';
let config = JSON.parse(fs.readFileSync('remix.json','utf8'));
if (!('db' in config) || config.db === undefined) throw new Error('Add a db section to remix.json');

Type guard

function hasDbConfig(config: unknown): config is { db: Record<string, unknown> } {
  return typeof config === 'object' && config !== null && 'db' in config && (config as any).db !== undefined;
}

Prevention

When it happens

Trigger: Running any `remix db <command>` where `remix.json` parses successfully but contains no `"db"` section (or it's null/misspelled/nested at the wrong level).

Common situations: Apps scaffolded without database support; hand-edited configs; `db` accidentally nested inside another key or removed during refactors.

Related errors


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