Open gregorwolf opened 5 years ago
Hi Gregor,
I think Supertest (https://www.npmjs.com/package/supertest) might be an option for API tests in node.js
I am not aware of any best practises by SAP in CAPM context.
BR Christian
I use mocha and chai for unit tests, I do not really see a way how to use them for integration tests that Gregor targets. I would say mocha and supertest might be worth a try, although I did not yet use supertest
I also think we can use mocha and supertest
Mocha and Supertest makes sense. Infact i was checking your existing app you have used Jasmine to test XSC app. Jasmine can also be used with NodeJS apps. I think we shall also check with @qmacro for his recommendations in this area and what SAP recommends.
PS: Mocha/Supertest looks okay.
What's about https://jestjs.io/ ?
Jest is what is used by here at SAP to test the Node.js parts of CAPM. Reason not to use Mocha + Chai + Istanbul + Sinon + Supertest is not wanting to manage the dependency issues between all our dev dependencies.
Thank you @chgeo for jumping in. Is it feasible to use Jest to call the OData API's locally and in a CI tool? Are there any public examples for that? Or could you contribute them ;-)?
As discussed.. we are working on guidelines.. will publish as soon as they are ready. Stay tuned :)
An inspiration for testing can be found in the openSAP HANA7 Course Exercise Materials
With #23 we have a first working test case. Feel free to create test cases based on the tests from the old SITreg backend
With #46 I've added API tests with Jasmine. Unfortunately the usedrequest library is deprecated. So this must still be migrated to axios.
Hello @balbinosoares @NabheetCloud @mattiastrr @lechnerc77,
thank you for all your contributions. Great to see them flowing in.
In SITreg I've created integration tests calling the OData API using users with the corresponding role assigned. I would like to follow this approach in CAPM too. What is the standard tool to run API tests in a NodeJS environment? Does SAP already posted some best practice?
In the next step we would also need to setup local authentication + authorizations to be able to test the different user roles.
Best regards Gregor