diff --git a/test/cds.ql.test.js b/test/cds.ql.test.js index 3af3327a..79c28fe3 100644 --- a/test/cds.ql.test.js +++ b/test/cds.ql.test.js @@ -1,5 +1,5 @@ +const { expect } = require('../test') const cds = require('@sap/cds/lib') -const { expect } = cds.test const CQL = ([cql]) => cds.parse.cql(cql) const Foo = { name: 'Foo' } const Books = { name: 'capire.bookshop.Books' } diff --git a/test/consuming-services.test.js b/test/consuming-services.test.js index ab550ef4..ff5c1b96 100644 --- a/test/consuming-services.test.js +++ b/test/consuming-services.test.js @@ -1,7 +1,7 @@ -const cds = require('@sap/cds/lib') -const { expect } = cds.test ( +const { expect } = require('../test') .run ( 'serve', 'AdminService', '--from', '@capire/bookshop,@capire/common', '--in-memory' -).in(__dirname) +) +const cds = require('@sap/cds/lib') describe('Consuming Services locally', () => { // diff --git a/test/custom-handlers.test.js b/test/custom-handlers.test.js index fd38c91f..c27779ae 100644 --- a/test/custom-handlers.test.js +++ b/test/custom-handlers.test.js @@ -1,5 +1,5 @@ +const { GET, POST, expect } = require('../test') .run ('bookshop') const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth -const { GET, POST, expect } = cds.test('bookshop').in(__dirname,'..') describe('Custom Handlers', () => { diff --git a/test/hello-world.test.js b/test/hello-world.test.js index d8f58a80..d833dce3 100644 --- a/test/hello-world.test.js +++ b/test/hello-world.test.js @@ -1,5 +1,4 @@ -const cds = require('@sap/cds/lib') -const { GET, expect } = cds.test('serve','hello/world.cds').in(__dirname,'..') +const { GET, expect } = require('../test') .run ('serve','hello/world.cds') describe('Hello world!', () => { diff --git a/test/hierarchical-data.test.js b/test/hierarchical-data.test.js index d92dfcf9..e411eff0 100644 --- a/test/hierarchical-data.test.js +++ b/test/hierarchical-data.test.js @@ -1,6 +1,5 @@ -const cwd = process.cwd(); process.chdir (__dirname) //> only for internal CI/CD@SAP +const {expect} = require('../test') const cds = require('@sap/cds/lib') -const {expect} = cds.test // monkey patching older releases: if (!cds.compile.cdl) cds.compile.cdl = cds.parse @@ -25,8 +24,6 @@ describe('Hierarchical Data', ()=>{ expect (cds.db.model) .to.exist }) - after(()=> process.chdir(cwd)) - it ('supports deeply nested inserts', ()=> INSERT.into (Cats, { ID:100, name:'Some Cats...', children:[ { ID:101, name:'Cat', children:[ diff --git a/test/index.js b/test/index.js new file mode 100644 index 00000000..c44d3400 --- /dev/null +++ b/test/index.js @@ -0,0 +1,6 @@ + +const test = require('@sap/cds/lib/utils/tests').in(__dirname,'..') +module.exports = Object.assign(test,{run:test}) + +// REVISIT: With upcoming release of @sap/cds this should become: +// module.exports = require('@sap/cds/tests').in(__dirname,'..') diff --git a/test/localized-data.test.js b/test/localized-data.test.js index c31fd43a..9c840830 100644 --- a/test/localized-data.test.js +++ b/test/localized-data.test.js @@ -1,5 +1,5 @@ +const { GET, expect } = require('../test') .run ('serve', 'test/localized-data.cds', '--in-memory') const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth -const { GET, expect } = cds.test ('serve', __dirname+'/localized-data.cds', '--in-memory') describe('Localized Data', () => { diff --git a/test/messaging.test.js b/test/messaging.test.js index 9c2e541d..ac76575c 100644 --- a/test/messaging.test.js +++ b/test/messaging.test.js @@ -1,13 +1,10 @@ +const { expect } = require('../test') const cds = require('@sap/cds/lib') -const cwd = process.cwd(); process.chdir (__dirname) //> only for internal CI/CD@SAP -const {expect} = cds.test const _model = '@capire/reviews' cds.User = cds.User.Privileged // hard core monkey patch describe('Messaging', ()=>{ - after(()=> process.chdir(cwd)) - it ('should bootstrap sqlite in-memory db', async()=>{ const db = await cds.deploy (_model) .to ('sqlite::memory:') await db.delete('Reviews') diff --git a/test/odata.test.js b/test/odata.test.js index db24ea3d..25a8c604 100644 --- a/test/odata.test.js +++ b/test/odata.test.js @@ -1,8 +1,9 @@ +const { GET, expect } = require('../test') .run ('bookshop') const cds = require('@sap/cds/lib'); cds.User = cds.User.Privileged // skip auth -const { GET, expect } = cds.test('bookshop').in(__dirname,'..') describe('OData Protocol', () => { + it('serves $metadata documents in v4', async () => { const { headers, status, data } = await GET `/browse/$metadata` expect(status).to.equal(200)