{"id":"4db87df5ce8d3725","repo":"vitest-dev/vitest","slug":"unexpected-value-for-expect-value-if-you-ne","errorCode":null,"errorMessage":"Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax","messagePattern":"Unexpected value for --expect: (.+?)\\. If you need to configure expect options, use --expect\\.(.+?)=<value> syntax","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/cli/cli-config.ts","lineNumber":825,"sourceCode":"          timeout: {\n            description:\n              'Poll timeout in milliseconds for `expect.poll()` assertions (default: `1000`)',\n            argument: '<timeout>',\n          },\n        },\n        transform(value) {\n          if (typeof value !== 'object') {\n            throw new TypeError(\n              `Unexpected value for --expect.poll: ${value}. If you need to configure timeout, use --expect.poll.timeout=<timeout>`,\n            )\n          }\n          return value\n        },\n      },\n    },\n    transform(value) {\n      if (typeof value !== 'object') {\n        throw new TypeError(\n          `Unexpected value for --expect: ${value}. If you need to configure expect options, use --expect.{name}=<value> syntax`,\n        )\n      }\n      return value\n    },\n  },\n  printConsoleTrace: {\n    description: 'Always print console stack traces',\n  },\n  includeTaskLocation: {\n    description: 'Collect test and suite locations in the `location` property',\n  },\n  attachmentsDir: {\n    description: 'The directory where attachments from `context.annotate` are stored in (default: `.vitest/attachments`)',\n    argument: '<dir>',\n  },\n\n  // CLI only options","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/cli/cli-config.ts#L807-L843","documentation":"Thrown by the `--expect` option transform when it receives a non-object value. `--expect` is a container for sub-options (e.g. requireAssertions, poll) and must be configured via dotted keys (`--expect.<name>=<value>`), not assigned a scalar directly.","triggerScenarios":"Passing `--expect=requireAssertions` as a value (string) instead of `--expect.requireAssertions`, or any scalar assigned to `--expect`. The transform checks `typeof value !== 'object'` and rejects scalars.","commonSituations":"Misreading the dotted-option syntax; trying to enable a boolean sub-option by attaching it as the parent flag's value; converting a config object to CLI flags incorrectly.","solutions":["Use the dotted key for the specific expect option, e.g. `--expect.requireAssertions`.","In a config file, use the object form `expect: { requireAssertions: true }`."],"exampleFix":"# before\nvitest --expect=requireAssertions\n# after\nvitest --expect.requireAssertions","handlingStrategy":"validation","validationCode":"if (typeof expectOpt !== 'object' || expectOpt === null) {\n  throw new Error('expect must be an object; use --expect.<name>=<value>')\n}","typeGuard":"function isExpectOptions(v: unknown): v is Record<string, unknown> {\n  return v !== null && typeof v === 'object'\n}","tryCatchPattern":null,"preventionTips":["Use dotted CLI keys for expect sub-options (e.g. --expect.requireAssertions).","In config files use the object form expect: { ... }.","Never assign a scalar to --expect."],"tags":[],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}