{"record":{"id":"0880ffd662fd7f34","repo":"tauri-apps/tauri","slug":"unexpected-value-for-test","errorCode":null,"errorMessage":"unexpected value for test","messagePattern":"unexpected value for test","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/context.rs","lineNumber":106,"sourceCode":"              } else {\n                return Err(syn::Error::new(\n                  input.span(),\n                  \"unexpected value for capabilities\",\n                ));\n              }\n            }\n            \"assets\" => {\n              assets.replace(v.value);\n            }\n            \"test\" => {\n              if let Expr::Lit(ExprLit {\n                lit: Lit::Bool(LitBool { value, .. }),\n                ..\n              }) = v.value\n              {\n                test = value;\n              } else {\n                return Err(syn::Error::new(input.span(), \"unexpected value for test\"));\n              }\n            }\n            name => {\n              return Err(syn::Error::new(\n                input.span(),\n                format!(\"unknown attribute {name}\"),\n              ));\n            }\n          }\n        }\n        Meta::List(_) => {\n          return Err(syn::Error::new(input.span(), \"unexpected list input\"));\n        }\n      }\n\n      let _ = input.parse::<Token![,]>();\n    }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macros/src/context.rs#L88-L124","documentation":"The test key of #[tauri::generate_context] toggles test mode (for example, skipping asset embedding so `cargo test` stays fast). Its value must be a boolean literal (Expr::Lit with Lit::Bool); the macro explicitly pattern-matches for it. Any other value — a quoted string, an ident, a const, Some(true) — fails with 'unexpected value for test'.","triggerScenarios":"#[tauri::generate_context(test = \"true\")], test = 1, or test = cfg!(test) / is_ci() — every non-literal-bool expression trips the else branch.","commonSituations":"Quoting true out of JSON habit; trying to enable test mode conditionally per cfg profile; assuming runtime/compile-time expressions are allowed in attribute values.","solutions":["Use the literal: #[tauri::generate_context(test = true)] or omit it (defaults to false)","For test-only behavior, gate tests with #[cfg(test)] instead of the attribute value","Remember macro attributes are static: build a generated invocation from build.rs if config must vary"],"exampleFix":"// before\n#[tauri::generate_context(test = \"true\")]\n// after\n#[tauri::generate_context(test = true)]","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["test takes a literal bool: test = true","Do not quote booleans out of JSON habit","Use #[cfg(test)] on the tests themselves instead of conditional attribute values"],"tags":["macros","generate-context","test-mode","compile-time","boolean-literal"],"backgroundTag":"macro-attribute-syntax-error","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}