Skip to content

Instantly share code, notes, and snippets.

@joaovictornsv
Last active June 14, 2021 12:35
Show Gist options
  • Save joaovictornsv/039bb193dac7056671916bbb13378511 to your computer and use it in GitHub Desktop.
Save joaovictornsv/039bb193dac7056671916bbb13378511 to your computer and use it in GitHub Desktop.
🔵 Setup Node Typescript
"rules": {
"camelcase":"off",
"no-console":"off",
"no-unused-vars": "warn",
"class-methods-use-this": "off",
"import/prefer-default-export": "off",
"import/extensions": [
"error",
"always",
{
"ts": "never",
"js": "never"
}
],
"consistent-return": "off"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".ts"]
},
"typescript": {}
}
}
module.exports = {
'*.ts': 'yarn test --findRelatedTests'
}
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
};
import { pathsToModuleNameMapper } from 'ts-jest/utils';
import { compilerOptions } from './tsconfig.json';
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
export default {
// Stop running tests after `n` failures
bail: true,
// Automatically clear mock calls and instances between every test
clearMocks: true,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
'src/controllers/*.ts',
'src/repositories/*.ts',
'src/services/*.ts',
'src/middlewares/*.ts',
'src/validators/*.ts',
],
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: [
"/node_modules/"
],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>' }),
// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',
// The test environment that will be used for testing
testEnvironment: "node",
// A map from regular expressions to paths to transformers
transform: undefined,
}
{
"name": "my_app",
"version": "1.0.0",
"main": "src/server.ts",
"license": "MIT",
"scripts": {
"dev": "tsnd -r tsconfig-paths/register --respawn --transpile-only --ignore-watch node_modules --no-notify src/server.ts",
"test": "NODE_ENV=test jest --runInBand --no-cache",
"test:coverage": "yarn test --coverage"
}
}
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
"target": "es2017",
"module": "commonjs",
"lib": ["es6"],
"allowJs": true,
"outDir": "./dist",
"rootDir": "./src",
"removeComments": true,
/* Strict Type-Checking Options */
"strict": false,
/* Module Resolution Options */
"baseUrl": ".",
"paths": {
"@config/*": ["./src/config/*"],
"@controllers/*": ["./src/controllers/*"],
"@entities/*": ["./src/entities/*"],
"@repositories/*": ["./src/repositories/*"],
"@views/*": ["./src/views/*"],
"@routers/*": ["./src/routers/*"],
"@services/*": ["./src/services/*"]
},
"esModuleInterop": true,
/* Experimental Options */
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
/* Advanced Options */
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["src/**/*"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment