diff --git a/package.json b/package.json index b33fb63c..80ab9df9 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,14 @@ "README.md" ], "scripts": { + "test:runtime": "npx tsc test/typescript/runtime.test.ts --target ES2020 --module commonjs && node --test './test/typescript/runtime.test.js'; rm test/typescript/runtime.test.js", + "test:api-calls": "node --test './test/typescript/apis/cds-api-calls.test.js'", + "test:typings": "node --test './test/typescript/cds-typings.test.js'", + "test:all": "npm run test:runtime && npm run test:api-calls && npm run test:typings", "test:setup": "npm install file:. --no-save --force && npm run prerelease:ci-fix", "test": "npm run test:setup && npm run test:rollup-on", - "test:rollup-on": "npm run rollup && npm run rollup:on && jest --silent", - "test:rollup-off": "npm run rollup:off && jest --silent", + "test:rollup-on": "npm run rollup && npm run rollup:on && npm run test:all --silent", + "test:rollup-off": "npm run rollup:off && npm run test:all --silent", "test:integration": "jest --testMatch \"**/test/**/*.integrationtest.js\"", "rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js", "rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true", diff --git a/test/typescript/runtime.test.ts b/test/typescript/runtime.test.ts index 6333fcd8..c821160b 100644 --- a/test/typescript/runtime.test.ts +++ b/test/typescript/runtime.test.ts @@ -185,11 +185,12 @@ describe('runtime tests', () => { cds.env.requires.db = { kind: 'sqlite' } // let { Books } = cds.entities - - expect (Service && cds.Service).toBe(Service) - expect (Request && cds.Request).toBe(Request) - expect (Event && cds.Event).toBe(Event) - expect (User && cds.User).toBe(User) + // classes are functions. .toBe therefore incorrectly tries to invoke the argument + // -> working around that by wrapping the class in an actual function to invoke + expect (Service && cds.Service).toBe(()=>Service) + expect (Request && cds.Request).toBe(()=>Request) + expect (Event && cds.Event).toBe(()=>Event) + expect (User && cds.User).toBe(()=>User) expect (cds.linked) class MyService extends cds.ApplicationService {}