diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 53d6fba13fe6..9f1caeaa615f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -63,13 +63,49 @@ "taskName": "Run loopback tests", "args": ["run", "test", "--scope", "loopback"] }, + { + "taskName": "Run loopback acceptance tests", + "args": ["run", "acceptance", "--scope", "loopback"] + }, + { + "taskName": "Run loopback integration tests", + "args": ["run", "integration", "--scope", "loopback"] + }, + { + "taskName": "Run loopback unit tests", + "args": ["run", "unit", "--scope", "loopback"] + }, { "taskName": "Run juggler tests", "args": ["run", "test", "--scope", "@loopback/juggler"] }, + { + "taskName": "Run juggler acceptance tests", + "args": ["run", "acceptance", "--scope", "@loopback/juggler"] + }, + { + "taskName": "Run juggler integration tests", + "args": ["run", "integration", "--scope", "@loopback/juggler"] + }, + { + "taskName": "Run juggler unit tests", + "args": ["run", "unit", "--scope", "@loopback/juggler"] + }, { "taskName": "Run remoting tests", "args": ["run", "test", "--scope", "@loopback/remoting"] - } + }, + { + "taskName": "Run remoting acceptance tests", + "args": ["run", "acceptance", "--scope", "@loopback/remoting"] + }, + { + "taskName": "Run remoting integration tests", + "args": ["run", "integration", "--scope", "@loopback/remoting"] + }, + { + "taskName": "Run remoting unit tests", + "args": ["run", "unit", "--scope", "@loopback/remoting"] + }, ] } \ No newline at end of file diff --git a/packages/juggler/package.json b/packages/juggler/package.json index 85b3e63ac431..8c2cee1347d8 100644 --- a/packages/juggler/package.json +++ b/packages/juggler/package.json @@ -4,15 +4,15 @@ "description": "", "main": "index.js", "scripts": { - "black-box": "mocha --opts ../../test/mocha.opts.black-box", - "test": "npm run white-box && npm run black-box", - "white-box": "mocha --opts ../../test/mocha.opts.white-box" + "acceptance": "mocha --opts ../../test/mocha.opts test/acceptance", + "integration": "mocha --opts ../../test/mocha.opts test/integration", + "test": "npm run unit && npm run integration && npm run acceptance", + "unit": "mocha --opts ../../test/mocha.opts test/unit" }, "author": "IBM", "license": "MIT", "devDependencies": { "@loopback/testlab": "^4.0.0-alpha.1", - "mocha": "^3.2.0", - "mocha-gherkin": "^0.2.0" + "mocha": "^3.2.0" } } diff --git a/packages/juggler/test/white-box/smoke.ts b/packages/juggler/test/acceptance/smoke.ts similarity index 56% rename from packages/juggler/test/white-box/smoke.ts rename to packages/juggler/test/acceptance/smoke.ts index 59d694a612dd..0e248e43ad19 100644 --- a/packages/juggler/test/white-box/smoke.ts +++ b/packages/juggler/test/acceptance/smoke.ts @@ -1,7 +1,7 @@ import {expect} from '@loopback/testlab'; -suite('white-box smoke test', () => { - test('passes', () => { +describe('acceptance smoke test', () => { + it('passes', () => { expect(true).to.be.true(); }); }); \ No newline at end of file diff --git a/packages/juggler/test/integration/smoke.ts b/packages/juggler/test/integration/smoke.ts new file mode 100644 index 000000000000..f7df6d05ed02 --- /dev/null +++ b/packages/juggler/test/integration/smoke.ts @@ -0,0 +1,7 @@ +import {expect} from '@loopback/testlab'; + +describe('integration smoke test', () => { + it('passes', () => { + expect(true).to.be.true(); + }); +}); \ No newline at end of file diff --git a/packages/juggler/test/black-box/smoke.ts b/packages/juggler/test/unit/smoke.ts similarity index 72% rename from packages/juggler/test/black-box/smoke.ts rename to packages/juggler/test/unit/smoke.ts index 1ecd24dc173f..9ba8736ab27a 100644 --- a/packages/juggler/test/black-box/smoke.ts +++ b/packages/juggler/test/unit/smoke.ts @@ -1,6 +1,6 @@ import {expect} from '@loopback/testlab'; -describe('white-box smoke test', () => { +describe('unit smoke test', () => { it('passes', () => { expect(true).to.be.true(); }); diff --git a/packages/loopback/package.json b/packages/loopback/package.json index 28aec5500e41..eb56a83630b4 100644 --- a/packages/loopback/package.json +++ b/packages/loopback/package.json @@ -4,9 +4,10 @@ "description": "", "main": "index.js", "scripts": { - "black-box": "mocha --opts ../../test/mocha.opts.black-box", - "test": "npm run white-box && npm run black-box", - "white-box": "mocha --opts ../../test/mocha.opts.white-box" + "acceptance": "mocha --opts ../../test/mocha.opts test/acceptance", + "integration": "mocha --opts ../../test/mocha.opts test/integration", + "test": "npm run unit && npm run integration && npm run acceptance", + "unit": "mocha --opts ../../test/mocha.opts test/unit" }, "author": "IBM", "license": "MIT", @@ -16,7 +17,6 @@ }, "devDependencies": { "@loopback/testlab": "^4.0.0-alpha.1", - "mocha": "^3.2.0", - "mocha-gherkin": "^0.2.0" + "mocha": "^3.2.0" } } diff --git a/packages/loopback/test/acceptance/bootstrapping/bootstrapping.ts b/packages/loopback/test/acceptance/bootstrapping/bootstrapping.ts new file mode 100644 index 000000000000..fb2651129822 --- /dev/null +++ b/packages/loopback/test/acceptance/bootstrapping/bootstrapping.ts @@ -0,0 +1,35 @@ +import {expect} from '@loopback/testlab'; +import * as util from 'loopback/test/support/util'; + +describe('bootstrapping the application', () => { + describe('with default configs', () => { + let app; + let client; + before(createApp); + before(createClient); + before(startApp); + + context('GET /', () => { + let response; + before(makeRequest); + + it('responds with HTTP 200', async () => { + expect(response.statusCode).to.equal(200); + }); + + async function makeRequest() { + response = await client.get('/') + } + }); + + function createApp() { + app = util.createApp(); + } + function createClient() { + client = util.createClient(app); + } + async function startApp() { + await app.start(); + } + }); +}); diff --git a/packages/loopback/test/acceptance/bootstrapping/feature.md b/packages/loopback/test/acceptance/bootstrapping/feature.md new file mode 100644 index 000000000000..bd7100600ac9 --- /dev/null +++ b/packages/loopback/test/acceptance/bootstrapping/feature.md @@ -0,0 +1,13 @@ +# Feature: Bootstrapping the application + +- In order to serve up my API +- As a user +- I want to start the application + +## Scenario: with default configs + +- Given an application +- And a client +- When I start the application +- And I send a request to GET / from the client +- Then the application responds with HTTP 200 diff --git a/packages/loopback/test/black-box/bootstrapping.ts b/packages/loopback/test/black-box/bootstrapping.ts deleted file mode 100644 index 5b0fbfe724fa..000000000000 --- a/packages/loopback/test/black-box/bootstrapping.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {expect} from '@loopback/testlab'; -import * as util from 'loopback/test/support/util'; - -Feature('Bootstrapping', - 'In order to serve up my API', - 'As a user', - 'I want to start the app', () => { - Scenario('with default configs', () => { - let app; - let client; - - Given('an app', () => { - app = util.createApp(); - }); - And('a client', () => { - client = util.createClient(app); - }); - When('the app is started (on port 3000 by default)', async () => { - await app.start(); - }); - Then('the app responds with HTTP 200 when a request is sent to GET /', async () => { - const result = await client.get('/') - expect(result.statusCode).to.equal(200); - }); - }); -}); \ No newline at end of file diff --git a/packages/loopback/test/black-box/crud/create/feature.md b/packages/loopback/test/black-box/crud/create/feature.md deleted file mode 100644 index f9f8d37ab03f..000000000000 --- a/packages/loopback/test/black-box/crud/create/feature.md +++ /dev/null @@ -1,11 +0,0 @@ -As a user I want to insert data in my collection - - Scenario: Inserting data into collections - Given an app - And a controller named NoteController - And a model named Model - And a data source named db using a memory connector - When I make a request to POST /notes - Then it inserts the data - And it responds with the id of the new data - And it has a status code of 200 \ No newline at end of file diff --git a/packages/loopback/test/black-box/crud/create/index.ts b/packages/loopback/test/black-box/crud/create/index.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/loopback/test/black-box/crud/delete/feature.md b/packages/loopback/test/black-box/crud/delete/feature.md deleted file mode 100644 index 0a097c57dbff..000000000000 --- a/packages/loopback/test/black-box/crud/delete/feature.md +++ /dev/null @@ -1,12 +0,0 @@ -As a user I want to delete data from my collection - - Scenario: Deleting data from collections - Given an app - And a controller named NoteController - And a model named Model - And a data source named db using a memory connector - And a record in the data source with id 123 - When I make a request to DELETE /notes/123 - Then it removes the record with id 123 - And it responds with the number of affected rows set to 1 - And it has a status code of 200 \ No newline at end of file diff --git a/packages/loopback/test/black-box/crud/delete/index.ts b/packages/loopback/test/black-box/crud/delete/index.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/loopback/test/black-box/crud/read/feature.md b/packages/loopback/test/black-box/crud/read/feature.md deleted file mode 100644 index 98834fb4aa69..000000000000 --- a/packages/loopback/test/black-box/crud/read/feature.md +++ /dev/null @@ -1,14 +0,0 @@ -As a user I read data from my collection - - Scenario: Reading collection data - Given an app - And a controller named NoteController - And a model named Model - And a data source named db using a memory connector - And a record in the data source with id 1 - And a record in the data source with id 2 - When I make a request to GET /notes - Then it responds with an array of 2 records - And one record has id 1 - And another item has id 2 - And it has a status code of 200 \ No newline at end of file diff --git a/packages/loopback/test/black-box/crud/read/index.ts b/packages/loopback/test/black-box/crud/read/index.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/loopback/test/black-box/crud/update/feature.md b/packages/loopback/test/black-box/crud/update/feature.md deleted file mode 100644 index 40b10c523ac6..000000000000 --- a/packages/loopback/test/black-box/crud/update/feature.md +++ /dev/null @@ -1,11 +0,0 @@ -As a user I want to update data in my collection - - Scenario: Updating collection data - Given an app - And a controller named NoteController - And a model named Model - And a data source named db using a memory connector - And a record in the data source with id 123 and name of foo - When I make a request to PATCH /notes/123 with name of bar - Then it modifies the record with id 123 to have a name of bar - And it has a status code of 200 \ No newline at end of file diff --git a/packages/loopback/test/black-box/crud/update/index.ts b/packages/loopback/test/black-box/crud/update/index.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/loopback/test/integration/smoke.ts b/packages/loopback/test/integration/smoke.ts new file mode 100644 index 000000000000..f7df6d05ed02 --- /dev/null +++ b/packages/loopback/test/integration/smoke.ts @@ -0,0 +1,7 @@ +import {expect} from '@loopback/testlab'; + +describe('integration smoke test', () => { + it('passes', () => { + expect(true).to.be.true(); + }); +}); \ No newline at end of file diff --git a/packages/loopback/test/unit/smoke.ts b/packages/loopback/test/unit/smoke.ts new file mode 100644 index 000000000000..42366f143f50 --- /dev/null +++ b/packages/loopback/test/unit/smoke.ts @@ -0,0 +1,7 @@ +import {expect} from '@loopback/testlab'; + +describe('unit smoke test', () => { + it('passes', () => { + expect(true).to.be.true(); + }); +}); diff --git a/packages/loopback/test/white-box/application.ts b/packages/loopback/test/white-box/application.ts deleted file mode 100644 index 6e86da386823..000000000000 --- a/packages/loopback/test/white-box/application.ts +++ /dev/null @@ -1,21 +0,0 @@ -import {Application, AppState} from 'loopback'; -import {expect} from '@loopback/testlab'; - -suite('Application', () => { - suite('constructor(config?: AppConfig)', () => { - test('without config arg', () => { - const app = new Application(); - expect(app.config).to.be.an('object'); - expect(app.config.port).to.eql(3000); - }); - }) - - suite('start()', () => { - test('when state is cold', async () => { - const app = new Application(); - expect(app.state).to.equal(AppState.cold); - await app.start(); - expect(app.state).to.equal(AppState.listening); - }); - }); -}); \ No newline at end of file diff --git a/packages/remoting/package.json b/packages/remoting/package.json index de3db5072c5b..6c96c72fa0cb 100644 --- a/packages/remoting/package.json +++ b/packages/remoting/package.json @@ -2,17 +2,17 @@ "name": "@loopback/remoting", "version": "4.0.0-alpha.1", "description": "", - "main": "index.js", + "main": "remoting", "scripts": { - "black-box": "mocha --opts ../../test/mocha.opts.black-box", - "test": "npm run white-box && npm run black-box", - "white-box": "mocha --opts ../../test/mocha.opts.white-box" + "acceptance": "mocha --opts ../../test/mocha.opts test/acceptance", + "integration": "mocha --opts ../../test/mocha.opts test/integration", + "test": "npm run unit && npm run integration && npm run acceptance", + "unit": "mocha --opts ../../test/mocha.opts test/unit" }, "author": "IBM", "license": "MIT", "devDependencies": { "@loopback/testlab": "^4.0.0-alpha.1", - "mocha": "^3.2.0", - "mocha-gherkin": "^0.2.0" + "mocha": "^3.2.0" } } diff --git a/packages/remoting/test/white-box/smoke.ts b/packages/remoting/test/acceptance/smoke.ts similarity index 56% rename from packages/remoting/test/white-box/smoke.ts rename to packages/remoting/test/acceptance/smoke.ts index 59d694a612dd..0e248e43ad19 100644 --- a/packages/remoting/test/white-box/smoke.ts +++ b/packages/remoting/test/acceptance/smoke.ts @@ -1,7 +1,7 @@ import {expect} from '@loopback/testlab'; -suite('white-box smoke test', () => { - test('passes', () => { +describe('acceptance smoke test', () => { + it('passes', () => { expect(true).to.be.true(); }); }); \ No newline at end of file diff --git a/packages/remoting/test/integration/smoke.ts b/packages/remoting/test/integration/smoke.ts new file mode 100644 index 000000000000..f7df6d05ed02 --- /dev/null +++ b/packages/remoting/test/integration/smoke.ts @@ -0,0 +1,7 @@ +import {expect} from '@loopback/testlab'; + +describe('integration smoke test', () => { + it('passes', () => { + expect(true).to.be.true(); + }); +}); \ No newline at end of file diff --git a/packages/remoting/test/black-box/smoke.ts b/packages/remoting/test/unit/smoke.ts similarity index 72% rename from packages/remoting/test/black-box/smoke.ts rename to packages/remoting/test/unit/smoke.ts index 83d993cb3383..9ba8736ab27a 100644 --- a/packages/remoting/test/black-box/smoke.ts +++ b/packages/remoting/test/unit/smoke.ts @@ -1,6 +1,6 @@ import {expect} from '@loopback/testlab'; -describe('black-box smoke test', () => { +describe('unit smoke test', () => { it('passes', () => { expect(true).to.be.true(); }); diff --git a/packages/testlab/tsconfig.json b/packages/testlab/tsconfig.json deleted file mode 100644 index 4369662a423d..000000000000 --- a/packages/testlab/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.json", - "baseUrl": "." -} \ No newline at end of file diff --git a/test/global-types.d.ts b/test/global-types.d.ts deleted file mode 100644 index 9f34505566aa..000000000000 --- a/test/global-types.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare var And : any; -declare var Feature : Function; -declare var Given : any; -declare var Scenario : any; -declare var Then : any; -declare var When : any; \ No newline at end of file diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 000000000000..a3855b8341e2 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,3 @@ +--compilers ts:tsconfig-paths/register +--recursive +--require ../../test/ts-node diff --git a/test/mocha.opts.black-box b/test/mocha.opts.black-box deleted file mode 100644 index ec5e22a8ddd7..000000000000 --- a/test/mocha.opts.black-box +++ /dev/null @@ -1,4 +0,0 @@ ---require ../../test/ts-node.js ---compilers ts:tsconfig-paths/register ---ui mocha-gherkin --reporter mocha-gherkin/build/spec -test/black-box/**/*.ts diff --git a/test/mocha.opts.white-box b/test/mocha.opts.white-box deleted file mode 100644 index d857598404e6..000000000000 --- a/test/mocha.opts.white-box +++ /dev/null @@ -1,4 +0,0 @@ ---require ../../test/ts-node.js ---compilers ts:tsconfig-paths/register ---ui tdd -test/white-box/**/*.ts