Skip to content

Commit 3abb5a5

Browse files
committed
update config
1 parent 9b801f9 commit 3abb5a5

File tree

5 files changed

+228
-47
lines changed

5 files changed

+228
-47
lines changed

.github/workflows/code_health.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run: npm ci
2020
- name: Run style check
2121
run: npm run check
22-
22+
2323
run-tests:
2424
runs-on: ubuntu-latest
2525
steps:

jest.config.js

Lines changed: 199 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,207 @@
1-
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2-
export default {
3-
preset: 'ts-jest/presets/default-esm',
4-
testEnvironment: 'node',
5-
extensionsToTreatAsEsm: ['.ts'],
1+
/**
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
/** @type {import('jest').Config} */
7+
const config = {
8+
// All imported modules in your tests should be mocked automatically
9+
// automock: false,
10+
11+
// Stop running tests after `n` failures
12+
// bail: 0,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/private/var/folders/4_/m2t0ys455s308pbmbv71ft1w0000gp/T/jest_dy",
16+
17+
// Automatically clear mock calls, instances, contexts and results before every test
18+
// clearMocks: false,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
// collectCoverage: false,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: undefined,
25+
26+
// The directory where Jest should output its coverage files
27+
// coverageDirectory: undefined,
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
// coveragePathIgnorePatterns: [
31+
// "/node_modules/"
32+
// ],
33+
34+
// Indicates which provider should be used to instrument code for coverage
35+
// coverageProvider: "babel",
36+
37+
// A list of reporter names that Jest uses when writing coverage reports
38+
// coverageReporters: [
39+
// "json",
40+
// "text",
41+
// "lcov",
42+
// "clover"
43+
// ],
44+
45+
// An object that configures minimum threshold enforcement for coverage results
46+
// coverageThreshold: undefined,
47+
48+
// A path to a custom dependency extractor
49+
// dependencyExtractor: undefined,
50+
51+
// Make calling deprecated APIs throw helpful error messages
52+
// errorOnDeprecated: false,
53+
54+
// The default configuration for fake timers
55+
// fakeTimers: {
56+
// "enableGlobally": false
57+
// },
58+
59+
// Force coverage collection from ignored files using an array of glob patterns
60+
// forceCoverageMatch: [],
61+
62+
// A path to a module which exports an async function that is triggered once before all test suites
63+
// globalSetup: undefined,
64+
65+
// A path to a module which exports an async function that is triggered once after all test suites
66+
// globalTeardown: undefined,
67+
68+
// A set of global variables that need to be available in all test environments
69+
// globals: {},
70+
71+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
72+
// maxWorkers: "50%",
73+
74+
// An array of directory names to be searched recursively up from the requiring module's location
75+
// moduleDirectories: [
76+
// "node_modules"
77+
// ],
78+
79+
// An array of file extensions your modules use
80+
// moduleFileExtensions: [
81+
// "js",
82+
// "mjs",
83+
// "cjs",
84+
// "jsx",
85+
// "ts",
86+
// "tsx",
87+
// "json",
88+
// "node"
89+
// ],
90+
91+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
692
moduleNameMapper: {
793
'^(\\.{1,2}/.*)\\.js$': '$1',
894
},
95+
96+
97+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
98+
// modulePathIgnorePatterns: [],
99+
100+
// Activates notifications for test results
101+
// notify: false,
102+
103+
// An enum that specifies notification mode. Requires { notify: true }
104+
// notifyMode: "failure-change",
105+
106+
// A preset that is used as a base for Jest's configuration
107+
preset: 'ts-jest/presets/default-esm',
108+
109+
// Run tests from one or more projects
110+
// projects: undefined,
111+
112+
// Use this configuration option to add custom reporters to Jest
113+
// reporters: undefined,
114+
115+
// Automatically reset mock state before every test
116+
// resetMocks: false,
117+
118+
// Reset the module registry before running each individual test
119+
// resetModules: false,
120+
121+
// A path to a custom resolver
122+
// resolver: undefined,
123+
124+
// Automatically restore mock state and implementation before every test
125+
// restoreMocks: false,
126+
127+
// The root directory that Jest should scan for tests and modules within
128+
// rootDir: undefined,
129+
130+
// A list of paths to directories that Jest should use to search for files in
131+
// roots: [
132+
// "<rootDir>"
133+
// ],
134+
135+
// Allows you to use a custom runner instead of Jest's default test runner
136+
// runner: "jest-runner",
137+
138+
// The paths to modules that run some code to configure or set up the testing environment before each test
139+
// setupFiles: [],
140+
141+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
142+
// setupFilesAfterEnv: [],
143+
144+
// The number of seconds after which a test is considered as slow and reported as such in the results.
145+
// slowTestThreshold: 5,
146+
147+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
148+
// snapshotSerializers: [],
149+
150+
// The test environment that will be used for testing
151+
testEnvironment: "node",
152+
extensionsToTreatAsEsm: ['.ts'],
153+
154+
// Options that will be passed to the testEnvironment
155+
// testEnvironmentOptions: {},
156+
157+
// Adds a location field to test results
158+
// testLocationInResults: false,
159+
160+
// The glob patterns Jest uses to detect test files
161+
testMatch: [
162+
"**/__tests__/**/*.[jt]s?(x)",
163+
"**/?(*.)+(spec|test).[tj]s?(x)"
164+
],
165+
166+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
167+
// testPathIgnorePatterns: [
168+
// "/node_modules/"
169+
// ],
170+
171+
// The regexp pattern or array of patterns that Jest uses to detect test files
172+
// testRegex: [],
173+
174+
// This option allows the use of a custom results processor
175+
// testResultsProcessor: undefined,
176+
177+
// This option allows use of a custom test runner
178+
// testRunner: "jest-circus/runner",
179+
180+
// A map from regular expressions to paths to transformers
9181
transform: {
10182
'^.+\\.tsx?$': ['ts-jest', {
11183
useESM: true,
12184
}],
13185
},
14-
testMatch: [
15-
'**/tests/**/*.test.ts'
16-
],
17-
collectCoverageFrom: [
18-
'src/**/*.ts',
19-
'!src/**/index.ts',
20-
'!**/node_modules/**'
21-
],
22-
};
186+
187+
188+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
189+
// transformIgnorePatterns: [
190+
// "/node_modules/",
191+
// "\\.pnp\\.[^\\/]+$"
192+
// ],
193+
194+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
195+
// unmockedModulePathPatterns: undefined,
196+
197+
// Indicates whether each individual test should be reported during the run
198+
// verbose: undefined,
199+
200+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
201+
// watchPathIgnorePatterns: [],
202+
203+
// Whether to use watchman for file crawling
204+
// watchman: true,
205+
};
206+
207+
export default config;

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
"check:format": "prettier -c .",
3030
"reformat": "prettier --write .",
3131
"generate": "./scripts/generate.sh",
32-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
33-
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
34-
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage"
32+
"test": "jest"
3533
},
3634
"license": "Apache-2.0",
3735
"devDependencies": {

tests/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
This directory contains tests for the Atlas MCP Server. We use Jest as our testing framework along with TypeScript.
44

5-
65
## Running Tests
76

87
You can run tests using the following npm scripts:

tests/unit/index.test.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
import { jest, describe, it, expect, beforeEach } from '@jest/globals';
1+
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
22
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
33

44
// Mock modules
5-
jest.mock('@modelcontextprotocol/sdk/server/stdio', () => ({
6-
StdioServerTransport: jest.fn().mockImplementation(() => ({} as Transport))
5+
jest.mock("@modelcontextprotocol/sdk/server/stdio", () => ({
6+
StdioServerTransport: jest.fn().mockImplementation(() => ({}) as Transport),
77
}));
88

99
// Properly type the mock function to return Promise<void>
1010
const mockConnect = jest.fn<() => Promise<void>>().mockResolvedValue();
11-
jest.mock('../../src/server', () => ({
12-
Server: jest.fn().mockImplementation(() => ({
13-
state: undefined,
14-
apiClient: undefined,
15-
initialized: false,
16-
connect: mockConnect,
17-
}))
11+
jest.mock("../../src/server", () => ({
12+
Server: jest.fn().mockImplementation(() => ({
13+
state: undefined,
14+
apiClient: undefined,
15+
initialized: false,
16+
connect: mockConnect,
17+
})),
1818
}));
1919

20-
describe('Server initialization', () => {
21-
beforeEach(() => {
22-
jest.clearAllMocks();
23-
jest.resetModules();
24-
});
20+
describe("Server initialization", () => {
21+
beforeEach(() => {
22+
jest.clearAllMocks();
23+
jest.resetModules();
24+
});
2525

26-
it('should create a server instance', async () => {
27-
// Import these after mocking
28-
const { Server } = await import('../../src/server');
29-
const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio');
30-
31-
// Import the module under test
32-
await import('../../src/index');
33-
34-
expect(Server).toHaveBeenCalledTimes(1);
35-
expect(StdioServerTransport).toHaveBeenCalledTimes(1);
36-
expect(mockConnect).toHaveBeenCalledTimes(1);
37-
});
38-
});
26+
it("should create a server instance", async () => {
27+
const { Server } = await import("../../src/server");
28+
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio");
29+
30+
// Import the module under test
31+
await import("../../src/index");
32+
33+
expect(Server).toHaveBeenCalledTimes(1);
34+
expect(StdioServerTransport).toHaveBeenCalledTimes(1);
35+
expect(mockConnect).toHaveBeenCalledTimes(1);
36+
});
37+
});

0 commit comments

Comments
 (0)