cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Use cds.test() for Testing On-Premise Connections with Jest in SAP BAS?

fabi2295
Participant
313

Hello SAP Community,

I'm working on a CAP project in SAP Business Application Studio (BAS) where I need to run automated tests (cds.test()) involving connections to on-premise environments using Jest.

Specifically, I want to:

  1. Configure the cds.test() environment to connect to on-premise systems securely.
  2. Simulate a hybrid setup where some services use on-premise data while others remain in the cloud.
  3. Run the tests locally in BAS while respecting the connection settings for both environments.

Here's an example of a test where I attempt a POST request to an OData service connected to ECC and validate the error response:

 

 

it('POST ECC', async () => {
    try {
        // where the connection to ECC is made
        const { status } = await POST('/odata/v4/<Service>/<EntitySet>',
            {
                CNPJ: '1234',
                Pedido: '1234'
            },
            {
                headers: {
                    'Authorization': authHeader
                }
            });
        expect(status).toEqual(201); //code 400 Failed to destination
});

 

 

Has anyone successfully configured and run such a setup? Any guidance, best practices, or examples would be greatly appreciated!

Thanks in advance for your help! 😊

Accepted Solutions (0)

Answers (1)

Answers (1)

martinstenzig
Contributor
0 Kudos

I would create a separate testing profile that has the necessary connection information and then use cds.test with a profile reference. Any reason that would not work for you?