Skip to content

Commit

Permalink
feat: improve main script code and testability
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Hugo Salgado <vsalgadopb@gmail.com>
  • Loading branch information
vitorsalgado committed Mar 29, 2022
1 parent a143554 commit 976896c
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 143 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
npm run test:ci
- name: Coverage
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v2
timeout-minutes: 5
env:
Expand Down
2 changes: 1 addition & 1 deletion build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ENV PATH /opt/node_app/node_modules/.bin:$PATH

CMD ["dist/index.js"]
CMD ["dist/main.js"]
2 changes: 1 addition & 1 deletion cmd/create-nodejs-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ App: ${app}
const pkg = FsExt.readJsonSync(makePath(source, 'package.json'))
const newPkg = {
name: app,
main: 'dist/index.js',
main: 'dist/main.js',
}

PkgFieldsToKeep.forEach(field => {
Expand Down
21 changes: 11 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import 'dotenv/config'

const isCI = process.env.CI === 'true'

export default {
verbose: true,
collectCoverage: false,
resetModules: true,
restoreMocks: true,
testEnvironment: 'node',
transform: {},
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
globals: {
'ts-jest': {
tsconfig: './tsconfig.test.json',
useESM: true,
},
},
collectCoverageFrom: ['**/src/*/**/*.ts', '!**/__fixtures__/**', '!**/__tests__/**'],
collectCoverageFrom: ['<rootDir>/src/*.ts'],
coveragePathIgnorePatterns: ['<rootDir>/dist/', '/node_modules/', '<rootDir>/scripts', '<rootDir>/tools'],
testPathIgnorePatterns: ['<rootDir>/dist/', '/node_modules/', '<rootDir>/scripts', '<rootDir>/tools'],
coverageThreshold: {
global: {
branches: 10,
functions: 10,
lines: 10,
statements: 10,
},
},
coverageProvider: 'v8',
coverageReporters: isCI ? ['json'] : ['text'],
}
Loading

0 comments on commit 976896c

Please sign in to comment.