{"record":{"id":"7c0db4ac8618df99","repo":"karatelabs/karate","slug":"expect-to-no-such-api","errorCode":null,"errorMessage":"expect().to - no such api: ","messagePattern":"expect\\(\\)\\.to - no such api: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/match/Expect.java","lineNumber":489,"sourceCode":"                yield new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n            }\n            case \"have\" -> expectToHave;\n            case \"match\" -> (JavaCallable) (context, args) -> {\n                Result result;\n                if (subject instanceof String s) {\n                    if (args[0] instanceof JsRegex regex) {\n                        result = regex.test(s) ? Result.PASS : Result.fail(\"actual: \" + s + \", expected: \" + regex);\n                    } else {\n                        result = Result.fail(\"not a regex: \" + args[0]);\n                    }\n                } else {\n                    result = Result.fail(\"not a string\");\n                }\n                handleResult(context, result);\n                return new Expect(subject, false, onResult, throwOnFailure, contextSupplier);\n            };\n            case \"not\" -> new Expect(subject, !negated, onResult, throwOnFailure, contextSupplier).expectTo;\n            default -> throw new RuntimeException(\"expect().to - no such api: \" + key);\n        };\n    }\n\n    // ========== SimpleObject Implementation ==========\n\n    @Override\n    public Object jsGet(String key) {\n        if (\"to\".equals(key)) {\n            return expectTo;\n        }\n        if (\"not\".equals(key)) {\n            return new Expect(subject, true, onResult, throwOnFailure, contextSupplier);\n        }\n        if (\"that\".equals(key) || \"and\".equals(key) || \"which\".equals(key)) {\n            return this; // language chains\n        }\n        if (\"be\".equals(key) || \"is\".equals(key)) {\n            return expectToBe; // shorthand for .to.be","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/match/Expect.java#L471-L507","documentation":"Unknown-API guard in initExpectTo: the property chained after expect().to is not a supported continuation (be, have, match, include, etc.). Fires on a misspelled or unsupported expect DSL key; the message appends the invalid key.","triggerScenarios":"expect(x).to.<key>(...) with an unsupported key, e.g. .to.throw(fn), .to.be.a('string') misspelled routing, .to.respondTo, or typos like .to.contians.","commonSituations":"Porting Chai/Mocha tests (.to.throw, .to.be.a) directly to Karate; typos; using sinon/chai plugin vocabulary.","solutions":["Map unsupported Chai assertions to Karate equivalents (match expressions, karate.match(), plain JS/Java checks)","Use supported chains: expect(x).to.equal(y), .to.contain(z), .to.match(regex), .not.to...","Fix typos — the message prints the exact unrecognized key"],"exampleFix":"// before\nexpect(fn).to.throw(Error) // no such api: throw\n// after\n* karate.signal(fnResultAvailable) // or use try/catch style in JS block","handlingStrategy":"validation","validationCode":"var toKeys = ['that','and','which','equal','eql','include','contain','deep','be','exist','have','match','not'];\nif (toKeys.indexOf(key) < 0) throw 'unsupported .to key: ' + key;","typeGuard":null,"tryCatchPattern":"try { expect(x).to.equal(y); } catch (e) { karate.log('unsupported key: ' + e.message); }","preventionTips":["Do not port .to.throw/.to.be.a/.to.respondTo from Chai — use JS try/catch or match expressions","Verify each chained verb against the supported list","Rely on editor syntax highlighting/autocomplete for Karate DSL"],"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"}