Skip to content

Commit 3b5f0b4

Browse files
authored
feat: add unit test framework (#13)
1 parent af190c4 commit 3b5f0b4

File tree

8 files changed

+7973
-4886
lines changed

8 files changed

+7973
-4886
lines changed

.github/workflows/code_health.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,17 @@ jobs:
1919
run: npm ci
2020
- name: Run style check
2121
run: npm run check
22+
23+
run-tests:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version-file: package.json
31+
cache: "npm"
32+
- name: Install dependencies
33+
run: npm ci
34+
- name: Run tests
35+
run: npm test

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ This project implements a Model Context Protocol (MCP) server for MongoDB and Mo
5757

5858
4. Commit your changes with a descriptive commit message
5959

60+
## Adding tests to the MCP Server
61+
62+
When adding new features or fixing bugs, please ensure that you also add tests to cover your changes. This helps maintain the quality and reliability of the codebase.
63+
64+
## Running Tests
65+
66+
The tests can be found in the `tests` directory.
67+
68+
You can run tests using the following npm scripts:
69+
70+
- `npm test`: Run all tests
71+
72+
To run a specific test file or directory:
73+
74+
```bash
75+
npm test -- path/to/test/file.test.ts
76+
npm test -- path/to/directory
77+
```
78+
6079
## Troubleshooting
6180

6281
### Restart Server

jest.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
export default {
3+
preset: "ts-jest/presets/default-esm",
4+
testEnvironment: "node",
5+
extensionsToTreatAsEsm: [".ts"],
6+
moduleNameMapper: {
7+
"^(\\.{1,2}/.*)\\.js$": "$1", // Map .js to real paths for ESM
8+
},
9+
transform: {
10+
"^.+\\.tsx?$": [
11+
"ts-jest",
12+
{
13+
useESM: true,
14+
tsconfig: "tsconfig.jest.json", // Use specific tsconfig file for Jest
15+
},
16+
],
17+
},
18+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
19+
};

0 commit comments

Comments
 (0)