on 2023 Mar 28 10:25 AM
Hi Experts,
I try to follow the CAP Documentation regarding testing: https://cap.cloud.sap/docs/node.js/cds-test
Unfortunately, there is no information regarding testing a multitenant application.
So far, the only example I could find is this: https://github.com/SAP-samples/btp-cf-cap-multitenant-susaas/blob/advanced/test/test.js
I tested this in a small multitenant bookshop application and it works fine.
Then, I tried the same for my actual application (in my case, my profile is named "mtx"):
const cds = require('@sap/cds/lib')
const project = __dirname+'/..' // The project's root folder
//const { expect, GET } = cds.test(project) //<----------------------without mtx it works fine!
const { expect, GET } = cds.test(project,"--profile","mtx")
describe('Multitenancy is up and running', () => {
it('Subscribe for tenant t1', async () => {
var { 'cds.xt.DeploymentService': ds } = cds.services
await ds.subscribe("t1")
})
})
But with the mtx profile, I receive an error message, which mentions a timeout when running cds.test(). Is there a way to raise the cds.test() timeout to like 10 seconds or so? Or is this just a misleading error message, because when running without mtx, it's working fine.
Full error log:
● Multitenancy is up and running › Subscribe for tenant t1
thrown: "Exceeded timeout of 5000 ms for a hook.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.";
1 | const cds = require('@sap/cds/lib')
2 | const project = __dirname+'/..' // The project's root folder
> 3 | const { expect, GET } = cds.test(project,"--profile","mtx")
| ^
4 |
5 |
6 | describe('Multitenancy is up and running', () => {
at global.before (node_modules/@sap/cds/lib/utils/cds-test.js:108:40)
at Test.run (node_modules/@sap/cds/lib/utils/cds-test.js:21:5)
at cds.test (node_modules/@sap/cds/lib/utils/cds-test.js:167:62)
at Object.test (test/mtx.test.js:3:29)
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "[cds] - loaded model from 12 file(s):
".
at console.info (node_modules/@jest/console/build/BufferedConsole.js:153:10)
at Function.logger.info (node_modules/@sap/cds/lib/log/cds-log.js:93:59)
at cds.<anonymous> (node_modules/@sap/cds/bin/serve.js:263:9)
at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)
at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)
at node_modules/@sap/cds/lib/compile/load.js:28:25
at cds_server (node_modules/@sap/cds/server.js:42:15)
at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log " db/data-model.cds".
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log " node_modules/@sap/cds-mtxs/srv/bootstrap.cds".
at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)
at cds.<anonymous> (node_modules/@sap/cds/bin/serve.js:264:47)
at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)
at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)
at node_modules/@sap/cds/lib/compile/load.js:28:25
at cds_server (node_modules/@sap/cds/server.js:42:15)
at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log " node_modules/@sap/cds/common.cds".
at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)
at cds.<anonymous> (node_modules/@sap/cds/bin/serve.js:264:47)
at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)
at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)
at node_modules/@sap/cds/lib/compile/load.js:28:25
at cds_server (node_modules/@sap/cds/server.js:42:15)
at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "".
at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)
at cds.<anonymous> (node_modules/@sap/cds/bin/serve.js:265:13)
at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)
at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)
at node_modules/@sap/cds/lib/compile/load.js:28:25
at cds_server (node_modules/@sap/cds/server.js:42:15)
at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/mtx.test.js.
at Object.<anonymous> (node_modules/@sap/cds/lib/lazy.js:45:35)
at Object.get [as nodejs] (node_modules/@sap/cds/lib/lazy.js:34:40)
at cds_server (node_modules/@sap/cds/server.js:43:31)
Thanks & Regards,
Nico
Hi. A bit late, but to solve this problem, you need to increase the timeout of jest itself, through the testTimeout property. If you don't use jest, use it to solve the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.