<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: cds.test with multitenancy in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724997#M4775509</link>
    <description>&lt;P&gt;When running &lt;EM&gt;cds w --profile mtx&lt;/EM&gt; it takes 15.116s to start my application using the Business Application Studio. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[cds] - launched at 4/4/2023, 11:48:31 AM, version: 6.6.2, in: 15.116s&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This seems to be way too long for cds.test() (or jest), which is only waiting for 5s.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;thrown: "Exceeded timeout of 5000 ms for a hook.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Apr 2023 11:53:32 GMT</pubDate>
    <dc:creator>nicorunge</dc:creator>
    <dc:date>2023-04-04T11:53:32Z</dc:date>
    <item>
      <title>cds.test with multitenancy</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaq-p/12724994</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
  &lt;P&gt;I try to follow the CAP Documentation regarding testing: &lt;A href="https://cap.cloud.sap/docs/node.js/cds-test"&gt;https://cap.cloud.sap/docs/node.js/cds-test&lt;/A&gt;&lt;BR /&gt;Unfortunately, there is no information regarding testing a multitenant application.&lt;/P&gt;
  &lt;P&gt;So far, the only example I could find is this: &lt;A href="https://github.com/SAP-samples/btp-cf-cap-multitenant-susaas/blob/advanced/test/test.js"&gt;https://github.com/SAP-samples/btp-cf-cap-multitenant-susaas/blob/advanced/test/test.js&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I tested this in a small multitenant bookshop application and it works fine.&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;Then, I tried the same for my actual application (in my case, my profile is named "mtx"):&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;const cds = require('@sap/cds/lib')&lt;BR /&gt;const project = __dirname+'/..' // The project's root folder
//const { expect, GET } = cds.test(project) //&amp;lt;----------------------without mtx it works fine!
const { expect, GET } = cds.test(project,"--profile","mtx")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; describe('Multitenancy is up and running', () =&amp;gt; {&lt;BR /&gt;  it('Subscribe for tenant t1', async () =&amp;gt; {&lt;BR /&gt;    var { 'cds.xt.DeploymentService': ds } = cds.services&lt;BR /&gt;    await ds.subscribe("t1")&lt;BR /&gt;  })&lt;BR /&gt;}) &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;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.&lt;BR /&gt;&lt;BR /&gt;Full error log:&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;● Multitenancy is up and running › Subscribe for tenant t1&lt;BR /&gt;&lt;BR /&gt;    thrown: "Exceeded timeout of 5000 ms for a hook.&lt;BR /&gt;    Add a timeout value to this test to increase the timeout, if this is a long-running test. See &lt;A href="https://jestjs.io/docs/api#testname-fn-timeout.&amp;quot;" target="test_blank"&gt;https://jestjs.io/docs/api#testname-fn-timeout."&lt;/A&gt;;&lt;BR /&gt;&lt;BR /&gt;      1 | const cds = require('@sap/cds/lib')&lt;BR /&gt;      2 | const project = __dirname+'/..' // The project's root folder&lt;BR /&gt;    &amp;gt; 3 | const { expect, GET } = cds.test(project,"--profile","mtx")&lt;BR /&gt;        |                             ^&lt;BR /&gt;      4 |&lt;BR /&gt;      5 |&lt;BR /&gt;      6 |  describe('Multitenancy is up and running', () =&amp;gt; {&lt;BR /&gt;&lt;BR /&gt;      at global.before (node_modules/@sap/cds/lib/utils/cds-test.js:108:40)&lt;BR /&gt;      at Test.run (node_modules/@sap/cds/lib/utils/cds-test.js:21:5)&lt;BR /&gt;      at cds.test (node_modules/@sap/cds/lib/utils/cds-test.js:167:62)&lt;BR /&gt;      at Object.test (test/mtx.test.js:3:29)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?&lt;BR /&gt;    Attempted to log "[cds] - loaded model from 12 file(s):&lt;BR /&gt;    ".&lt;BR /&gt;&lt;BR /&gt;      at console.info (node_modules/@jest/console/build/BufferedConsole.js:153:10)&lt;BR /&gt;      at Function.logger.info (node_modules/@sap/cds/lib/log/cds-log.js:93:59)&lt;BR /&gt;      at cds.&amp;lt;anonymous&amp;gt; (node_modules/@sap/cds/bin/serve.js:263:9)&lt;BR /&gt;      at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)&lt;BR /&gt;      at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)&lt;BR /&gt;      at node_modules/@sap/cds/lib/compile/load.js:28:25&lt;BR /&gt;      at cds_server (node_modules/@sap/cds/server.js:42:15)&lt;BR /&gt;      at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?&lt;BR /&gt;    Attempted to log "  db/data-model.cds".&lt;BR /&gt;&lt;BR /&gt;
  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?&lt;BR /&gt;    Attempted to log "  node_modules/@sap/cds-mtxs/srv/bootstrap.cds".&lt;BR /&gt;&lt;BR /&gt;      at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)&lt;BR /&gt;      at cds.&amp;lt;anonymous&amp;gt; (node_modules/@sap/cds/bin/serve.js:264:47)&lt;BR /&gt;      at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)&lt;BR /&gt;      at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)&lt;BR /&gt;      at node_modules/@sap/cds/lib/compile/load.js:28:25&lt;BR /&gt;      at cds_server (node_modules/@sap/cds/server.js:42:15)&lt;BR /&gt;      at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?&lt;BR /&gt;    Attempted to log "  node_modules/@sap/cds/common.cds".&lt;BR /&gt;&lt;BR /&gt;      at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)&lt;BR /&gt;      at cds.&amp;lt;anonymous&amp;gt; (node_modules/@sap/cds/bin/serve.js:264:47)&lt;BR /&gt;      at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)&lt;BR /&gt;      at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)&lt;BR /&gt;      at node_modules/@sap/cds/lib/compile/load.js:28:25&lt;BR /&gt;      at cds_server (node_modules/@sap/cds/server.js:42:15)&lt;BR /&gt;      at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?&lt;BR /&gt;    Attempted to log "".&lt;BR /&gt;&lt;BR /&gt;      at console.log (node_modules/@jest/console/build/BufferedConsole.js:156:10)&lt;BR /&gt;      at cds.&amp;lt;anonymous&amp;gt; (node_modules/@sap/cds/bin/serve.js:265:13)&lt;BR /&gt;      at cds.emit (node_modules/@sap/cds/lib/index.js:18:23)&lt;BR /&gt;      at _finalize (node_modules/@sap/cds/lib/compile/load.js:33:22)&lt;BR /&gt;      at node_modules/@sap/cds/lib/compile/load.js:28:25&lt;BR /&gt;      at cds_server (node_modules/@sap/cds/server.js:42:15)&lt;BR /&gt;      at Object.serve (node_modules/@sap/cds/bin/serve.js:196:18)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/mtx.test.js.&lt;BR /&gt;&lt;BR /&gt;      at Object.&amp;lt;anonymous&amp;gt; (node_modules/@sap/cds/lib/lazy.js:45:35)&lt;BR /&gt;      at Object.get [as nodejs] (node_modules/@sap/cds/lib/lazy.js:34:40)&lt;BR /&gt;      at cds_server (node_modules/@sap/cds/server.js:43:31)&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Nico&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 09:25:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaq-p/12724994</guid>
      <dc:creator>nicorunge</dc:creator>
      <dc:date>2023-03-28T09:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: cds.test with multitenancy</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724995#M4775507</link>
      <description>&lt;P&gt;Have you tried increasing your timeout as below?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; describe('Multitenancy is up and running', () =&amp;gt; {&lt;BR /&gt;  it('Subscribe for tenant t1', async () =&amp;gt; {&lt;BR /&gt;    var { 'cds.xt.DeploymentService': ds } = cds.services&lt;BR /&gt;    await ds.subscribe("t1")&lt;BR /&gt;  },15000)&lt;BR /&gt;}) &lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Mar 2023 10:42:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724995#M4775507</guid>
      <dc:creator>alperdedeoglu18</dc:creator>
      <dc:date>2023-03-29T10:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: cds.test with multitenancy</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724996#M4775508</link>
      <description>&lt;P&gt;Hi Alper,&lt;/P&gt;&lt;P&gt;the error appears when it tries to run &lt;EM&gt;cds.test( )&lt;/EM&gt;, not when running the actual test. So extending the test timeout will not help. It seems like my application start up takes too long, when running in multitenancy. &lt;/P&gt;&lt;P&gt;BR, Nico&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 09:33:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724996#M4775508</guid>
      <dc:creator>nicorunge</dc:creator>
      <dc:date>2023-04-04T09:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: cds.test with multitenancy</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724997#M4775509</link>
      <description>&lt;P&gt;When running &lt;EM&gt;cds w --profile mtx&lt;/EM&gt; it takes 15.116s to start my application using the Business Application Studio. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[cds] - launched at 4/4/2023, 11:48:31 AM, version: 6.6.2, in: 15.116s&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This seems to be way too long for cds.test() (or jest), which is only waiting for 5s.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;thrown: "Exceeded timeout of 5000 ms for a hook.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 11:53:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/12724997#M4775509</guid>
      <dc:creator>nicorunge</dc:creator>
      <dc:date>2023-04-04T11:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: cds.test with multitenancy</title>
      <link>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/13609920#M4818775</link>
      <description>&lt;P&gt;Hi. A bit late, but to solve this problem, you need to increase the timeout of jest itself, through the &lt;STRONG&gt;testTimeout&lt;/STRONG&gt; property. If you don't use jest, use it to solve the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 12:26:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cds-test-with-multitenancy/qaa-p/13609920#M4818775</guid>
      <dc:creator>luanmateus</dc:creator>
      <dc:date>2024-02-19T12:26:00Z</dc:date>
    </item>
  </channel>
</rss>

