Skip to content

Commit d416cc1

Browse files
committed
Fix Node.js 20.x compatibility and add GitHub Actions workflow
1 parent afc5532 commit d416cc1

File tree

3 files changed

+13
-56
lines changed

3 files changed

+13
-56
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ jobs:
1515
node-version: [18.x, 20.x]
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- name: Checkout code
19+
uses: actions/checkout@v4
1920

20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
2223
with:
2324
node-version: ${{ matrix.node-version }}
2425
cache: 'npm'
@@ -28,73 +29,23 @@ jobs:
2829

2930
- name: Run unit tests
3031
run: npm run test:unit
31-
env:
32-
NODE_ENV: test
33-
MONGO_CONNECTION_STRING: mongodb://localhost:27017/edms-test
34-
SECRET_KEY: test-secret-key
35-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
36-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
37-
AWS_REGION: us-east-1
38-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
39-
EMAIL_USER: [email protected]
40-
EMAIL_PASS: test-password
4132

4233
- name: Run integration tests
4334
run: npm run test:integration
44-
env:
45-
NODE_ENV: test
46-
MONGO_CONNECTION_STRING: mongodb://localhost:27017/edms-test
47-
SECRET_KEY: test-secret-key
48-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
49-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
50-
AWS_REGION: us-east-1
51-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
52-
EMAIL_USER: [email protected]
53-
EMAIL_PASS: test-password
5435

5536
- name: Run security tests
5637
run: npm run test:security
57-
env:
58-
NODE_ENV: test
59-
MONGO_CONNECTION_STRING: mongodb://localhost:27017/edms-test
60-
SECRET_KEY: test-secret-key
61-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
62-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
63-
AWS_REGION: us-east-1
64-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
65-
EMAIL_USER: [email protected]
66-
EMAIL_PASS: test-password
6738

6839
- name: Run performance tests
6940
run: npm run test:performance
70-
env:
71-
NODE_ENV: test
72-
MONGO_CONNECTION_STRING: mongodb://localhost:27017/edms-test
73-
SECRET_KEY: test-secret-key
74-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
75-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
76-
AWS_REGION: us-east-1
77-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
78-
EMAIL_USER: [email protected]
79-
EMAIL_PASS: test-password
8041

8142
- name: Run CI tests
8243
run: npm run test:ci
83-
env:
84-
NODE_ENV: test
85-
MONGO_CONNECTION_STRING: mongodb://localhost:27017/edms-test
86-
SECRET_KEY: test-secret-key
87-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
88-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
89-
AWS_REGION: us-east-1
90-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
91-
EMAIL_USER: [email protected]
92-
EMAIL_PASS: test-password
9344

9445
- name: Generate test coverage
9546
run: npm run test:coverage
9647

97-
- name: Upload coverage to Codecov
48+
- name: Upload coverage reports
9849
uses: codecov/codecov-action@v3
9950
with:
10051
file: ./coverage/lcov.info

jest.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ module.exports = {
1616
coverageReporters: ['text', 'lcov', 'html'],
1717
verbose: true,
1818
testTimeout: 30000,
19-
// Handle ES modules
19+
// Handle ES modules and Node.js 20.x compatibility
2020
transformIgnorePatterns: [
2121
'node_modules/(?!(@vercel/analytics)/)'
2222
],
2323
// Mock Vercel Analytics for tests
2424
moduleNameMapper: {
2525
'^@vercel/analytics/server$': '<rootDir>/tests/mocks/vercel-analytics.mock.js'
26+
},
27+
// Ensure compatibility with Node.js 20.x
28+
globals: {
29+
'ts-jest': {
30+
useESM: true
31+
}
2632
}
2733
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"start": "node server.js",
2828
"test": "jest",
2929
"test:watch": "jest --watch",
30-
"test:coverage": "jest --coverage",
30+
"test:coverage": "jest --coverage --verbose",
3131
"test:unit": "jest tests/unit/",
3232
"test:integration": "jest tests/integration/",
3333
"test:security": "jest tests/security/",

0 commit comments

Comments
 (0)