Skip to content

Commit 2d958c9

Browse files
authored
Merge pull request #7 from tspascoal/add-unit-tests
Add unit tests for GitHub App token generation built task
2 parents b1907a3 + d1e209d commit 2d958c9

File tree

19 files changed

+6283
-324
lines changed

19 files changed

+6283
-324
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ jobs:
2929
run: npm ci
3030
working-directory: create-github-app-token
3131

32+
- name: Run tests
33+
run: npm test
34+
working-directory: create-github-app-token
35+
3236
- name: Build
3337
run: npm run build
3438
working-directory: create-github-app-token

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ lib
55

66
*.vsix
77
*.pem
8-
.taskkey
8+
.taskkey
9+
10+
coverage/

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ steps:
2323
displayName: 'Install dependencies'
2424
workingDirectory: create-github-app-token
2525

26+
- script: npm test
27+
displayName: 'Run unit tests'
28+
workingDirectory: create-github-app-token
29+
2630
- script: |
2731
npm run clean
2832
npm run build
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/src', '<rootDir>/test'],
5+
testMatch: ['**/test/**/*.test.ts'],
6+
collectCoverageFrom: [
7+
'src/**/*.{js,ts}',
8+
'!src/**/*.d.ts',
9+
'!**/node_modules/**'
10+
],
11+
coverageDirectory: 'coverage',
12+
coverageReporters: ['text', 'text-summary', 'lcov', 'html', 'json'],
13+
coveragePathIgnorePatterns: [
14+
'/node_modules/',
15+
'/test/',
16+
'/coverage/',
17+
'/.dist/',
18+
'/lib/'
19+
],
20+
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
21+
clearMocks: true,
22+
restoreMocks: true,
23+
24+
// Additional configuration for better test isolation
25+
resetMocks: true,
26+
resetModules: true,
27+
28+
// Transform configuration
29+
transform: {
30+
'^.+\\.ts$': ['ts-jest', {
31+
tsconfig: 'tsconfig.json'
32+
}]
33+
},
34+
35+
// Coverage thresholds (optional - adjust as needed)
36+
coverageThreshold: {
37+
global: {
38+
branches: 80,
39+
functions: 80,
40+
lines: 80,
41+
statements: 80
42+
}
43+
},
44+
45+
// Verbose output for better debugging
46+
verbose: true,
47+
48+
// Test timeout
49+
testTimeout: 10000
50+
};

0 commit comments

Comments
 (0)