{"record":{"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/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/cli/cli-config.ts#L807-L843","documentation":"The top-level `--expect` option is an object whose children are `--expect.{name}=<value>`. Passing a scalar to `--expect` itself (e.g. `--expect=foo`) is rejected because `typeof value !== 'object'` in its `transform`. The message directs users to the dotted-key syntax.","triggerScenarios":"`vitest --expect=foo`, `--expect 5`, or any non-object value reaching the outer `expect.transform`.","commonSituations":"Treating `--expect` as a feature toggle; misreading docs and passing an assertion filter through `--expect`; shell alias that concatenates a value onto `--expect`.","solutions":["Use dotted keys for the property you want: `--expect.poll.timeout=1000`, `--expect.assertions=5`, etc.","If you wanted no expect customization, remove the flag entirely.","Set the same values via the config file's `test.expect` object."],"exampleFix":"# before\nvitest run --expect=foo\n\n# after\nvitest run --expect.poll.timeout=1000","handlingStrategy":"validation","validationCode":"function assertExpectObject(v: unknown): asserts v is Record<string, unknown> {\n  if (v != null && typeof v !== 'object') {\n    throw new TypeError('--expect must be an object; use --expect.<name>=<value>')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass a scalar to `--expect`; always use dotted sub-keys.","Configure expect defaults in `test.expect` of the config file.","Audit shell aliases that append values to flags."],"tags":["cli","expect","options","transform"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}