Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/e2e-testing #42

Merged
merged 26 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ typings/
# Dist #
dist/
ormconfig.json
tsconfig.build.json

# IDE #
.idea/
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"cSpell.enabled": true
"cSpell.enabled": true,
"files.exclude": {
"tsconfig.build.json": true,
"ormconfig.json": true
}
}
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,14 @@ Try it!! We are happy to hear your feedback or any kind of new features.
- **API Documentation** thanks to [swagger](http://swagger.io/).
- **API Monitoring** thanks to [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor).
- **Integrated Testing Tool** thanks to [Jest](https://facebook.github.io/jest).
- **E2E API Testing** thanks to [supertest](https://github.com/visionmedia/supertest).
- **Basic Security Features** thanks to [Helmet](https://helmetjs.github.io/).
- **Easy event dispatching** thanks to [event-dispatch](https://github.com/pleerock/event-dispatch).
- **Fast Database Building** with simple migration from [TypeORM](https://github.com/typeorm/typeorm).
- **Easy Data Seeding** with our own factories.
- **GraphQL** provides as a awesome query language for our api [GraphQL](http://graphql.org/).
- **DataLoaders** helps with performance thanks to caching and batching [DataLoaders](https://github.com/facebook/dataloader).

### Comming soon

- **Custom Commands** are also available in our setup and really easy to use or even extend.
- **Scaffolding Commands** will speed up your development tremendously as you should focus on business code and not scaffolding.

# Table of Contents

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

- Run the unit tests using `npm start test` (There is also a vscode task for this called `test`).
- Run the integration tests using `npm start test:integration`.
- 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).
- Run the e2e tests using `npm start test:e2e`.

### Running in dev mode

Expand Down Expand Up @@ -329,7 +325,7 @@ export class CreateUsers implements SeedsInterface {
public async seed(factory: FactoryInterface): Promise<any> {
await factory
.get(User)
.create(10);
.createMany(10);
}

}
Expand All @@ -343,7 +339,7 @@ export class CreateUsers implements SeedsInterface {
public async seed(factory: FactoryInterface): Promise<any> {
await factory
.get(User, 'admin')
.create(1);
.create();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice when we could use create(10) and create() so we don't need an additional method createMany(x).

}

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

const pets: Pet[] = await factory.get(Pet)
.create(2);
.createMany(2);

const petIds = pets.map((pet: Pet) => pet.Id);
await user.pets().attach(petIds);
Expand Down Expand Up @@ -390,6 +386,8 @@ npm start db.seed
| [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! |
| [Auth0 API Documentation](https://auth0.com/docs/api/management/v2) | Authentification service |
| [Jest](http://facebook.github.io/jest/) | Delightful JavaScript Testing Library for unit and e2e tests |
| [supertest](https://github.com/visionmedia/supertest) | Super-agent driven library for testing node.js HTTP servers using a fluent API |
| [nock](https://github.com/node-nock/nock) | HTTP mocking and expectations library |
| [swagger Documentation](http://swagger.io/) | API Tool to describe and document your api. |
| [SQLite Documentation](https://www.sitepoint.com/getting-started-sqlite3-basic-commands/) | Getting Started with SQLite3 – Basic Commands. |
| [GraphQL Documentation](http://graphql.org/graphql-js/) | A query language for your API. |
Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions src/lib/ormconfig.ts → commands/ormconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import * as dotenv from 'dotenv';
dotenv.config();

import * as path from 'path';
import * as Chalk from 'chalk';
import * as jsonfile from 'jsonfile';
import { env } from '../core/env';
import { env } from '../src/core/env';


const content = {
Expand All @@ -23,8 +24,13 @@ const content = {
const filePath = path.join(process.cwd(), 'ormconfig.json');
jsonfile.writeFile(filePath, content, { spaces: 2 }, (err) => {
if (err === null) {
console.log('Successfully generated ormconfig.json form the .env file');
const chalk = Chalk.default;
console.log('👍 ',
chalk.gray.underline('generated:'),
chalk.blue.bold('ormconfig.json')
);
} else {
console.error('Failed to generate the ormconfig.json', err);
process.exit(1);
}
});
24 changes: 24 additions & 0 deletions commands/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as path from 'path';
import * as Chalk from 'chalk';
import * as jsonfile from 'jsonfile';
import * as tsconfig from '../tsconfig.json';


const content: any = tsconfig;
content.include = [
'src/**/*',
];

const filePath = path.join(process.cwd(), 'tsconfig.build.json');
jsonfile.writeFile(filePath, content, { spaces: 2 }, (err) => {
if (err === null) {
const chalk = Chalk.default;
console.log('👍 ',
chalk.gray.underline('generated:'),
chalk.blue.bold('tsconfig.build.json')
);
} else {
console.error('Failed to generate the otsconfig.build.json', err);
process.exit(1);
}
});
Loading