-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-utils): create pkg to test utils
- Loading branch information
Showing
14 changed files
with
359 additions
and
66 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<div align="center"> | ||
<img alt="nestjs-logo" width="250" height="auto" src="https://camo.githubusercontent.com/c704e8013883cc3a04c7657e656fe30be5b188145d759a6aaff441658c5ffae0/68747470733a2f2f6e6573746a732e636f6d2f696d672f6c6f676f5f746578742e737667" /> | ||
<h1>Tresdoce NestJs Toolkit<br/>Test-Utils</h1> | ||
</div> | ||
|
||
<div align="center"> | ||
<img src="https://img.shields.io/static/v1.svg?style=flat&label=Node&message=v14.17.0&labelColor=339933&color=757575&logoColor=FFFFFF&logo=Node.js" alt="Node.js"/> | ||
<img src="https://img.shields.io/static/v1.svg?style=flat&label=Npm&message=v6.14.13&labelColor=CB3837&logoColor=FFFFFF&color=757575&logo=npm" alt="Npm"/> | ||
<img src="https://img.shields.io/static/v1.svg?style=flat&label=NestJs&message=v8.2.6&labelColor=E0234E&logoColor=FFFFFF&color=757575&logo=Nestjs" alt="NestJs"/><br/> | ||
<img alt="GitHub license" src="https://img.shields.io/github/license/tresdoce/tresdoce-nestjs-toolkit?style=flat"> | ||
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/tresdoce/tresdoce-nestjs-toolkit?filename=packages%2Ftest-utils%2Fpackage.json"> | ||
<br/> | ||
</div> | ||
<br/> | ||
|
||
Este módulo está pensada para ser utilizada en [NestJs Starter](https://github.com/rudemex/nestjs-starter), o cualquier | ||
proyecto que utilice una configuración centralizada, siguiendo la misma arquitectura del starter. | ||
|
||
## Glosario | ||
|
||
- [🥳 Demo](https://rudemex-nestjs-starter.herokuapp.com/docs) | ||
- [📝 Requerimientos básicos](#basic-requirements) | ||
- [🛠️ Instalar dependencia](#install-dependencies) | ||
- [⚙️ Configuración](#configurations) | ||
- [👨💻 Uso](#use) | ||
- [📄 Changelog](./CHANGELOG.md) | ||
- [📜 License MIT](./license.md) | ||
|
||
--- | ||
|
||
<a name="basic-requirements"></a> | ||
|
||
## 📝 Requerimientos básicos | ||
|
||
- [NestJs Starter](https://github.com/rudemex/nestjs-starter) | ||
- Node.js v14.17.0 or higher ([Download](https://nodejs.org/es/download/)) | ||
- YARN v1.22.17 or higher | ||
- NPM v6.14.13 or higher | ||
- NestJS v8.2.6 or higher ([Documentación](https://nestjs.com/)) | ||
|
||
<a name="install-dependencies"></a> | ||
|
||
## 🛠️ Instalar dependencia | ||
|
||
``` | ||
npm install -S @tresdoce-nestjs-toolkit/test-utils | ||
``` | ||
|
||
``` | ||
yarn add @tresdoce-nestjs-toolkit/test-utils | ||
``` | ||
|
||
<a name="configurations"></a> | ||
|
||
## ⚙️ Configuración | ||
|
||
```typescript | ||
|
||
``` | ||
|
||
<a name="use"></a> | ||
|
||
## 👨💻 Uso | ||
|
||
```typescript | ||
|
||
``` | ||
|
||
## 📄 Changelog | ||
|
||
Todos los cambios notables de este paquete se documentarán en el archivo [Changelog](./CHANGELOG.md). | ||
|
||
--- | ||
|
||
<div align="center"> | ||
<a href="mailto:mdelgado@tresdoce.com.ar" target="_blank" alt="Send an email"> | ||
<img src="../../.readme-static/logo-mex-red.svg" width="120" alt="Mex" /> | ||
</a><br/> | ||
<p>Made with ❤</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const config = require('@tresdoce-nestjs-toolkit/config/jest.config'); | ||
|
||
module.exports = { | ||
...config, | ||
rootDir: __dirname, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 - present Tresdoce & Maximiliano "Mex" Delgado <mdelgado@tresdoce.com.ar> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"name": "@tresdoce-nestjs-toolkit/test-utils", | ||
"version": "0.0.0", | ||
"description": "Tresdoce NestJS Toolkit - test-utils", | ||
"author": { | ||
"name": "Maximiliano \"Mex\" Delgado", | ||
"email": "mdelgado@tresdoce.com.ar", | ||
"url": "https://rudemex.github.io/" | ||
}, | ||
"directories": { | ||
"lib": "lib", | ||
"test": "__tests__" | ||
}, | ||
"keywords": [ | ||
"nestjs", | ||
"test-utils" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tresdoce/tresdoce-nestjs-toolkit.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/tresdoce/tresdoce-nestjs-toolkit/issues" | ||
}, | ||
"homepage": "https://github.com/tresdoce/tresdoce-nestjs-toolkit#readme", | ||
"main": "src/index.ts", | ||
"license": "MIT", | ||
"scripts": { | ||
"prebuild": "shx rm -rf pkg", | ||
"build": "pika build --out ../../dist/test-utils", | ||
"test": "jest --runInBand --detectOpenHandles --coverage" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"directory": "../../dist/test-utils" | ||
}, | ||
"peerDependencies": { | ||
"@nestjs/common": "^8.2.0", | ||
"@nestjs/core": "^8.2.0", | ||
"@nestjs/platform-express": "^8.2.0", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.5.5" | ||
}, | ||
"devDependencies": { | ||
"@tresdoce-nestjs-toolkit/config": "^0.0.0", | ||
"@types/tresdoce-nestjs-toolkit": "^0.0.0" | ||
}, | ||
"prettier": { | ||
"semi": true, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"trailingComma": "all" | ||
}, | ||
"@pika/pack": { | ||
"pipeline": [ | ||
[ | ||
"@pika/plugin-ts-standard-pkg", | ||
{ | ||
"exclude": [ | ||
"**/__test__/*" | ||
] | ||
} | ||
], | ||
[ | ||
"@pika/plugin-build-node", | ||
{ | ||
"exclude": [ | ||
"**/__test__/*" | ||
] | ||
} | ||
], | ||
[ | ||
"@pika/plugin-build-types", | ||
{ | ||
"exclude": [ | ||
"**/__test__/*" | ||
] | ||
} | ||
] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import { GreetingModule } from '../greeting/greeting.module'; | ||
|
||
describe('GreetingModule', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [GreetingModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { GreetingService } from '../greeting/services/greeting.service'; | ||
|
||
describe('GreetingService', () => { | ||
let service: GreetingService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [GreetingService], | ||
}).compile(); | ||
|
||
service = module.get<GreetingService>(GreetingService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
it('should be return message when call the getHello function', () => { | ||
expect(service.getHello()).toBe('¡Hello from the new package test-utils!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { GreetingService } from './services/greeting.service'; | ||
|
||
@Global() | ||
@Module({ | ||
providers: [GreetingService], | ||
exports: [GreetingService], | ||
}) | ||
export class GreetingModule {} |
8 changes: 8 additions & 0 deletions
8
packages/test-utils/src/greeting/services/greeting.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class GreetingService { | ||
getHello(): string { | ||
return '¡Hello from the new package test-utils!'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// export public api from here | ||
// for example: | ||
// export * from './decorators'; | ||
export * from './greeting/greeting.module'; | ||
export * from './greeting/services/greeting.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"exclude": [ | ||
"node_modules", | ||
"dist", | ||
"test", | ||
"__test__", | ||
"**/__test__/**/*", | ||
"**/*spec.ts", | ||
"**/*it.ts", | ||
"**/*test.ts", | ||
"**/*e2e.ts", | ||
"**/*e2e-spec.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": "@tresdoce-nestjs-toolkit/config", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"types": ["tresdoce-nestjs-toolkit"] | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": [ | ||
"node_modules", | ||
"dist", | ||
"test", | ||
"__test__", | ||
"**/__test__/**/*", | ||
"**/*spec.ts", | ||
"**/*it.ts", | ||
"**/*test.ts", | ||
"**/*e2e.ts", | ||
"**/*e2e-spec.ts", | ||
"coverage" | ||
] | ||
} |
Oops, something went wrong.