{"record":{"id":"6a1cf79b49465460","repo":"karatelabs/karate","slug":"expect-to-have-no-such-api","errorCode":null,"errorMessage":"expect().to.have - no such api: ","messagePattern":"expect\\(\\)\\.to\\.have - no such api: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/match/Expect.java","lineNumber":457,"sourceCode":"                }\n                handleResult(context, result);\n                // Return chainable with property value as new subject for .and.equal() chaining\n                return new Expect(propertyValue != null ? propertyValue : subject, false, onResult, throwOnFailure, contextSupplier);\n            };\n            case \"keys\" -> (JavaCallable) (context, args) -> {\n                Result result;\n                if (subject instanceof Map<?, ?> map) {\n                    result = evaluate(map.keySet(), Match.Type.CONTAINS_ONLY, args[0]);\n                } else {\n                    result = Result.fail(\"not an object\");\n                }\n                handleResult(context, result);\n                return new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n            };\n            case \"all\" -> expectToHaveAll;\n            case \"any\" -> expectToHaveAny;\n            case \"nested\" -> expectToHaveNested;\n            default -> throw new RuntimeException(\"expect().to.have - no such api: \" + key);\n        };\n    }\n\n    private SimpleObject initExpectTo() {\n        return key -> switch (key) {\n            case \"that\", \"and\", \"which\" -> this;\n            case \"equal\", \"eql\" -> match(Match.Type.EQUALS);\n            case \"include\", \"contain\" -> matchChainable(Match.Type.CONTAINS);\n            case \"deep\" -> expectToDeep;\n            case \"be\" -> expectToBe;\n            case \"exist\" -> {\n                Result result = (subject != null && subject != Terms.UNDEFINED) ? Result.PASS : Result.fail(\"actual: \" + subject + \", expected: (exists)\");\n                handleResult(null, result);\n                yield new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n            }\n            case \"have\" -> expectToHave;\n            case \"match\" -> (JavaCallable) (context, args) -> {\n                Result result;","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/match/Expect.java#L439-L475","documentation":"Unknown-API guard in initExpectToHave: the property chained after expect().to.have is not one of the supported assertion APIs (property access, keys, etc.). Fires on misspelled DSL keys; the message appends the invalid key.","triggerScenarios":"expect(obj).to.have.<key>(...) with an unsupported key such as .to.have.length(n) (use .to.have.size? — only supported keys work), .to.have.string, or typos like propreties.","commonSituations":"Chai idioms like .to.have.lengthOf, .to.have.property misspelled; assuming all Chai vocabulary exists in Karate.","solutions":["Use supported keys: expect(x).to.have.property('name') / .to.have.keys(...) / .all / .any / .nested.property(...)","For length/size use expect(list.size() == 3) or match each/list syntax","Consult the expect() API docs for the exact key list"],"exampleFix":"// before\nexpect(list).to.have.length(3) // no such api: length\n// after\nexpect(list.size() == 3)","handlingStrategy":"validation","validationCode":"var haveKeys = ['property','properties','keys','all','any','nested'];\nif (haveKeys.indexOf(key) < 0) throw 'unsupported .to.have key: ' + key;","typeGuard":null,"tryCatchPattern":"try { expect(obj).to.have.property('name'); } catch (e) { karate.log(e.message); }","preventionTips":["Map Chai .to.have.lengthOf to list.size() or match each syntax","Use only supported keys: property/properties, keys, all, any, nested","Keep team-wide assertion style guide for Karate expect()"],"tags":["expect","unsupported-key","bdd-assertion"],"backgroundTag":"invalid-enum-value","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}