Skip to content

Instantly share code, notes, and snippets.

View Farenheith's full-sized avatar

Thiago Oliveira Santos Farenheith

  • Grupo Boticário
  • São Paulo, Brazil
View GitHub Profile
@Farenheith
Farenheith / tslint.json
Last active January 2, 2020 19:04
Valid tslint example
{
"extends": "gts/tslint.json"
}
@Farenheith
Farenheith / .editorconfig
Last active January 2, 2020 19:13
A simple example for .editorconfig file
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
[*.{ts,js,json}]
indent_style = tab
trim_trailing_whitespace = true
@Farenheith
Farenheith / .gitignore
Created January 2, 2020 19:48
.gitignore example
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
@Farenheith
Farenheith / tsconfig.base.json
Created January 2, 2020 20:12
tsconfig.json configuration example
{
"extends": "gts/tsconfig-google.json",
"compilerOptions": {
"outDir": "build",
"lib": [
"es2017",
"dom",
],
"moduleResolution": "node",
"experimentalDecorators": true,
@Farenheith
Farenheith / mocha.opts
Created January 2, 2020 20:39
Mocha configuration example
# mocha.opts
--require test/ts-node-register.js
test/setup.spec.js
--recursive test/**/*.spec.ts
@Farenheith
Farenheith / .nycrc.json
Created January 2, 2020 20:56
nyc config example
{
"check-coverage": true,
"lines": 95,
"branches": 95,
"functions": 95,
"exclude": [
"test",
"build",
"coverage",
"dist",
@Farenheith
Farenheith / gulpfile-clear.js
Last active January 2, 2020 23:24
gulpfile-clear.js example
var gulp = require('gulp');
var del = require('del');
gulp.task('default', function () {
return del([
'build/'
]);
});
@Farenheith
Farenheith / setup.spec.ts
Created January 12, 2020 14:50
Exmaple of setup for unit tests
import 'reflect-metadata';
import { use } from 'chai';
import { restore } from 'sinon';
import sinonChai = require('sinon-chai');
use(sinonChai);
afterEach(() => {
restore();
});
@Farenheith
Farenheith / testsuiteexample.spec.ts
Last active January 12, 2020 19:09
An example of test suite
import { stub, SinonStub } from 'sinon';
// First describe, class name
describe('MyClass', () => {
let service: MyService;
let target: MyClass;
// Class describe beforeEach, class bootstrap
beforeEach(() => {
service = {} as any;
@Farenheith
Farenheith / index.spec.ts
Created January 12, 2020 19:22
An example of unit test for a simple main file
import { stub, SinonStub } from 'sinon';
import * as server from '../src/server';
// First describe, class name
describe('index.ts', () => {
let start: SinonStub;
// Before each to bootstrap stubs, where all the methods that could be called are stubbeds
beforeEach(() => {
start = sinon.stub(server, 'start');