Skip to content

Commit 018cf87

Browse files
author
Gery Hirschfeld
authored
Merge pull request #42 from w3tecch/feature/e2e
Feature/e2e-testing
2 parents c4c269c + 7700cab commit 018cf87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+753
-279
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typings/
2121
# Dist #
2222
dist/
2323
ormconfig.json
24+
tsconfig.build.json
2425

2526
# IDE #
2627
.idea/

.vscode/settings.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"typescript.tsdk": "./node_modules/typescript/lib",
3-
"cSpell.enabled": true
3+
"cSpell.enabled": true,
4+
"files.exclude": {
5+
"tsconfig.build.json": true,
6+
"ormconfig.json": true
7+
}
48
}

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ Try it!! We are happy to hear your feedback or any kind of new features.
4242
- **API Documentation** thanks to [swagger](http://swagger.io/).
4343
- **API Monitoring** thanks to [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor).
4444
- **Integrated Testing Tool** thanks to [Jest](https://facebook.github.io/jest).
45+
- **E2E API Testing** thanks to [supertest](https://github.com/visionmedia/supertest).
4546
- **Basic Security Features** thanks to [Helmet](https://helmetjs.github.io/).
4647
- **Easy event dispatching** thanks to [event-dispatch](https://github.com/pleerock/event-dispatch).
4748
- **Fast Database Building** with simple migration from [TypeORM](https://github.com/typeorm/typeorm).
4849
- **Easy Data Seeding** with our own factories.
4950
- **GraphQL** provides as a awesome query language for our api [GraphQL](http://graphql.org/).
5051
- **DataLoaders** helps with performance thanks to caching and batching [DataLoaders](https://github.com/facebook/dataloader).
5152

52-
### Comming soon
53-
54-
- **Custom Commands** are also available in our setup and really easy to use or even extend.
55-
- **Scaffolding Commands** will speed up your development tremendously as you should focus on business code and not scaffolding.
56-
5753
# Table of Contents
5854

5955
- [Getting Started](#getting-started)
@@ -133,7 +129,7 @@ All script are defined in the package.json file, but the most important ones are
133129

134130
- Run the unit tests using `npm start test` (There is also a vscode task for this called `test`).
135131
- Run the integration tests using `npm start test:integration`.
136-
- Run the e2e tests using `npm start test:e2e` and don't forget to start your application and your [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server).
132+
- Run the e2e tests using `npm start test:e2e`.
137133

138134
### Running in dev mode
139135

@@ -329,7 +325,7 @@ export class CreateUsers implements SeedsInterface {
329325
public async seed(factory: FactoryInterface): Promise<any> {
330326
await factory
331327
.get(User)
332-
.create(10);
328+
.createMany(10);
333329
}
334330

335331
}
@@ -343,7 +339,7 @@ export class CreateUsers implements SeedsInterface {
343339
public async seed(factory: FactoryInterface): Promise<any> {
344340
await factory
345341
.get(User, 'admin')
346-
.create(1);
342+
.create();
347343
}
348344

349345
}
@@ -357,7 +353,7 @@ await factory.get(User)
357353
.each(async (user: User) => {
358354

359355
const pets: Pet[] = await factory.get(Pet)
360-
.create(2);
356+
.createMany(2);
361357

362358
const petIds = pets.map((pet: Pet) => pet.Id);
363359
await user.pets().attach(petIds);
@@ -390,6 +386,8 @@ npm start db.seed
390386
| [Helmet](https://helmetjs.github.io/) | Helmet helps you secure your Express apps by setting various HTTP headers. It’s not a silver bullet, but it can help! |
391387
| [Auth0 API Documentation](https://auth0.com/docs/api/management/v2) | Authentification service |
392388
| [Jest](http://facebook.github.io/jest/) | Delightful JavaScript Testing Library for unit and e2e tests |
389+
| [supertest](https://github.com/visionmedia/supertest) | Super-agent driven library for testing node.js HTTP servers using a fluent API |
390+
| [nock](https://github.com/node-nock/nock) | HTTP mocking and expectations library |
393391
| [swagger Documentation](http://swagger.io/) | API Tool to describe and document your api. |
394392
| [SQLite Documentation](https://www.sitepoint.com/getting-started-sqlite3-basic-commands/) | Getting Started with SQLite3 – Basic Commands. |
395393
| [GraphQL Documentation](http://graphql.org/graphql-js/) | A query language for your API. |
File renamed without changes.

src/lib/ormconfig.ts commands/ormconfig.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import * as dotenv from 'dotenv';
22
dotenv.config();
33

44
import * as path from 'path';
5+
import * as Chalk from 'chalk';
56
import * as jsonfile from 'jsonfile';
6-
import { env } from '../core/env';
7+
import { env } from '../src/core/env';
78

89

910
const content = {
@@ -23,8 +24,13 @@ const content = {
2324
const filePath = path.join(process.cwd(), 'ormconfig.json');
2425
jsonfile.writeFile(filePath, content, { spaces: 2 }, (err) => {
2526
if (err === null) {
26-
console.log('Successfully generated ormconfig.json form the .env file');
27+
const chalk = Chalk.default;
28+
console.log('👍 ',
29+
chalk.gray.underline('generated:'),
30+
chalk.blue.bold('ormconfig.json')
31+
);
2732
} else {
2833
console.error('Failed to generate the ormconfig.json', err);
34+
process.exit(1);
2935
}
3036
});

commands/tsconfig.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as path from 'path';
2+
import * as Chalk from 'chalk';
3+
import * as jsonfile from 'jsonfile';
4+
import * as tsconfig from '../tsconfig.json';
5+
6+
7+
const content: any = tsconfig;
8+
content.include = [
9+
'src/**/*',
10+
];
11+
12+
const filePath = path.join(process.cwd(), 'tsconfig.build.json');
13+
jsonfile.writeFile(filePath, content, { spaces: 2 }, (err) => {
14+
if (err === null) {
15+
const chalk = Chalk.default;
16+
console.log('👍 ',
17+
chalk.gray.underline('generated:'),
18+
chalk.blue.bold('tsconfig.build.json')
19+
);
20+
} else {
21+
console.error('Failed to generate the otsconfig.build.json', err);
22+
process.exit(1);
23+
}
24+
});

0 commit comments

Comments
 (0)