Skip to content

Commit 976896c

Browse files
committed
feat: improve main script code and testability
Signed-off-by: Vitor Hugo Salgado <[email protected]>
1 parent a143554 commit 976896c

File tree

10 files changed

+507
-143
lines changed

10 files changed

+507
-143
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
npm run test:ci
5858
5959
- name: Coverage
60+
if: matrix.os == 'ubuntu-latest'
6061
uses: codecov/codecov-action@v2
6162
timeout-minutes: 5
6263
env:

build/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ ARG NODE_ENV=production
2222
ENV NODE_ENV $NODE_ENV
2323
ENV PATH /opt/node_app/node_modules/.bin:$PATH
2424

25-
CMD ["dist/index.js"]
25+
CMD ["dist/main.js"]

cmd/create-nodejs-ts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ App: ${app}
105105
const pkg = FsExt.readJsonSync(makePath(source, 'package.json'))
106106
const newPkg = {
107107
name: app,
108-
main: 'dist/index.js',
108+
main: 'dist/main.js',
109109
}
110110

111111
PkgFieldsToKeep.forEach(field => {

jest.config.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import 'dotenv/config'
22

3+
const isCI = process.env.CI === 'true'
4+
35
export default {
46
verbose: true,
57
collectCoverage: false,
8+
resetModules: true,
69
restoreMocks: true,
10+
testEnvironment: 'node',
711
transform: {},
812
preset: 'ts-jest/presets/default-esm',
913
extensionsToTreatAsEsm: ['.ts'],
14+
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
15+
moduleNameMapper: {
16+
'^(\\.{1,2}/.*)\\.js$': '$1',
17+
},
1018
globals: {
1119
'ts-jest': {
1220
tsconfig: './tsconfig.test.json',
1321
useESM: true,
1422
},
1523
},
16-
collectCoverageFrom: ['**/src/*/**/*.ts', '!**/__fixtures__/**', '!**/__tests__/**'],
24+
collectCoverageFrom: ['<rootDir>/src/*.ts'],
1725
coveragePathIgnorePatterns: ['<rootDir>/dist/', '/node_modules/', '<rootDir>/scripts', '<rootDir>/tools'],
18-
testPathIgnorePatterns: ['<rootDir>/dist/', '/node_modules/', '<rootDir>/scripts', '<rootDir>/tools'],
19-
coverageThreshold: {
20-
global: {
21-
branches: 10,
22-
functions: 10,
23-
lines: 10,
24-
statements: 10,
25-
},
26-
},
26+
coverageProvider: 'v8',
27+
coverageReporters: isCI ? ['json'] : ['text'],
2728
}

0 commit comments

Comments
 (0)