diff --git a/test/acceptance/ping.controller.acceptance.ts b/test/acceptance/ping.controller.acceptance.ts index 058bccdbb..e669620cc 100644 --- a/test/acceptance/ping.controller.acceptance.ts +++ b/test/acceptance/ping.controller.acceptance.ts @@ -3,26 +3,22 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; -import {RestServer} from '@loopback/rest'; +import {createRestAppClient, Client, expect} from '@loopback/testlab'; import {ShoppingApplication} from '../..'; describe('PingController', () => { let app: ShoppingApplication; - let server: RestServer; - let client: supertest.SuperTest; + let client: Client; before(givenAnApplication); - before(givenARestServer); - before(async () => { await app.boot(); await app.start(); }); before(() => { - client = createClientForHandler(server.requestHandler); + client = createRestAppClient(app); }); after(async () => { @@ -41,8 +37,4 @@ describe('PingController', () => { }, }); } - - async function givenARestServer() { - server = await app.getServer(RestServer); - } }); diff --git a/test/acceptance/shopping-cart.controller.acceptance.ts b/test/acceptance/shopping-cart.controller.acceptance.ts index 7dcfcd374..c469329f1 100644 --- a/test/acceptance/shopping-cart.controller.acceptance.ts +++ b/test/acceptance/shopping-cart.controller.acceptance.ts @@ -3,8 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; -import {RestServer} from '@loopback/rest'; +import {createRestAppClient, Client, expect} from '@loopback/testlab'; import {ShoppingApplication} from '../..'; import {ShoppingCartRepository} from '../../src/repositories'; import {RedisDataSource} from '../../src/datasources'; @@ -12,21 +11,18 @@ import {ShoppingCart, ShoppingCartItem} from '../../src/models'; describe('ShoppingCartController', () => { let app: ShoppingApplication; - let server: RestServer; - let client: supertest.SuperTest; + let client: Client; const cartRepo = new ShoppingCartRepository(new RedisDataSource()); before(givenAnApplication); - before(givenARestServer); - before(async () => { await app.boot(); await app.start(); }); before(() => { - client = createClientForHandler(server.requestHandler); + client = createRestAppClient(app); }); beforeEach(clearDatabase); @@ -109,10 +105,6 @@ describe('ShoppingCartController', () => { }); } - async function givenARestServer() { - server = await app.getServer(RestServer); - } - async function clearDatabase() { await cartRepo.deleteAll(); } diff --git a/test/acceptance/user.controller.acceptance.ts b/test/acceptance/user.controller.acceptance.ts index 7a5025f1a..c4cbd9f80 100644 --- a/test/acceptance/user.controller.acceptance.ts +++ b/test/acceptance/user.controller.acceptance.ts @@ -3,16 +3,14 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; -import {RestServer} from '@loopback/rest'; +import {createRestAppClient, Client, expect} from '@loopback/testlab'; import {ShoppingApplication} from '../..'; import {UserRepository} from '../../src/repositories'; import {UserDataSource} from '../../src/datasources'; describe('UserController', () => { let app: ShoppingApplication; - let server: RestServer; - let client: supertest.SuperTest; + let client: Client; const userRepo = new UserRepository(new UserDataSource()); const user = { @@ -24,15 +22,13 @@ describe('UserController', () => { before(givenAnApplication); - before(givenARestServer); - before(async () => { await app.boot(); await app.start(); }); before(() => { - client = createClientForHandler(server.requestHandler); + client = createRestAppClient(app); }); beforeEach(clearDatabase); @@ -124,10 +120,6 @@ describe('UserController', () => { }); } - async function givenARestServer() { - server = await app.getServer(RestServer); - } - async function clearDatabase() { await userRepo.deleteAll(); }