Skip to content

Commit b1df687

Browse files
committed
comit jest test cases
1 parent 5d2a18d commit b1df687

54 files changed

Lines changed: 5702 additions & 1267 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build project
31+
run: npm run build
32+
33+
- name: Run tests
34+
env:
35+
LM_ACCOUNT: ${{ secrets.LM_ACCOUNT }}
36+
LM_BEARER_TOKEN: ${{ secrets.LM_BEARER_TOKEN }}
37+
LOG_LEVEL: error
38+
CLEANUP_ON_FAILURE: true
39+
run: npm test
40+
41+
- name: Upload coverage reports
42+
if: matrix.node-version == '20.x'
43+
uses: codecov/codecov-action@v4
44+
with:
45+
file: ./coverage/lcov.info
46+
flags: unittests
47+
name: codecov-umbrella
48+
continue-on-error: true
49+
50+
- name: Archive test results
51+
if: always()
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: test-results-node-${{ matrix.node-version }}
55+
path: |
56+
coverage/
57+
*.log
58+
retention-days: 7
59+

jest.config.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export default {
2+
preset: 'ts-jest/presets/default-esm',
3+
testEnvironment: 'node',
4+
extensionsToTreatAsEsm: ['.ts'],
5+
moduleNameMapper: {
6+
'^(\\.{1,2}/.*)\\.js$': '$1',
7+
},
8+
transform: {
9+
'^.+\\.ts$': [
10+
'ts-jest',
11+
{
12+
useESM: true,
13+
tsconfig: {
14+
module: 'ESNext',
15+
moduleResolution: 'node',
16+
esModuleInterop: true,
17+
rootDir: '.',
18+
strict: false,
19+
},
20+
},
21+
],
22+
},
23+
testMatch: [
24+
'**/tests/**/*.test.ts',
25+
],
26+
testPathIgnorePatterns: [
27+
'/node_modules/',
28+
'/dist/',
29+
],
30+
collectCoverageFrom: [
31+
'src/**/*.ts',
32+
'!src/**/*.d.ts',
33+
'!src/index.ts',
34+
],
35+
coverageDirectory: 'coverage',
36+
coverageReporters: ['text', 'lcov', 'html'],
37+
coverageThreshold: {
38+
global: {
39+
branches: 50,
40+
functions: 50,
41+
lines: 50,
42+
statements: 50,
43+
},
44+
},
45+
testTimeout: 30000,
46+
verbose: true,
47+
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
48+
};
49+

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"build": "tsc",
1414
"start": "node dist/index.js",
1515
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js",
16-
"test": "jest",
16+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
17+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
18+
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
19+
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=tests/tools",
1720
"test:client": "node tests/test-client.js",
1821
"test:headers": "node tests/test-headers.js",
1922
"test:session": "node tests/test-session.js",

0 commit comments

Comments
 (0)