on 2024 Nov 04 7:23 AM
I have a CAPM application and that has an action which uses an external API call via destination. In local , I do 'hybrid" test that resolves the "cds bound" service , including destinations .
I am now intending to writer a test suite for these services. So , I do this. (Followed this blog )
let service = cds.test("serve",'--profile' ,'hybrid','--resolve-bindings' ).verbose();
But , its not resolving the destination services and throws an error
Error during request to remote service: Failed to load destination.
Any luck ? dependency versions are
@Dinu am I doing any obvious mistakes here ?
Request clarification before answering.
@catano Thanks for checking this. And equally I am glad that it works with your code base ( sighs with relief ) . Below is my code ( cleaned )
const cds = require("@sap/cds");
const chai = require("chai");
const chaiHttp = require("chai-http");
chai.use(chaiHttp);
chai.should();
let service = cds.test("serve",'--profile' ,'hybrid','--resolve-bindings' );
const { GET, POST } = service;
//using basic authentication ( mock )
const auth = {
auth: {
username: 'sreeharip',
password: 'password'
}
};
describe("Starting service", async () => {
it("Metadata retrieval", async () => {
let metadata = await GET("/dealmgmt-srv/$metadata", auth);
chai.expect(metadata).status(200);
}).timeout(60 * 1000);
it("Destination call", async () => {
// test is a function , that consumes a destination service - this call works fine in
// "cds watch --profile hybrd" or "cds serve --profile hybrid"
// and "cds serve --profile hybrid --resolve-bindings"
let testOutcome = await GET("/dealmgmt-srv/test()", auth);
chai.expect(testOutcome).status(200);
}).timeout(60 * 1000);
});
in the logs , I dont see the cloud foundry bindings being resolved -
( could this be the mocked authentication ) - destination is password credentials type, that doesn't expect the jwt .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I put the code in a public repo - I have kept the .cdsrc-private.json
https://github.com/sreehari-pillai-atom/capm-unit-testing-hybrid
User | Count |
---|---|
77 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.