Skip to content

Conversation

jake-danton
Copy link

Jest v30 has performance improvements. However, while ts-jest claims it works with jest@30 as a peer dependency, it requires a number of changes to the project tsconfig to get it working. Whereas, switching to @swc/jest works with jest@29 and jest@30 and it's ~2x as fast as ts-jest even before updating to jest@30.

Current test execution time:

Time:        3.454 s, estimated 6 s

Moving to @swc/jest:

Time:        1.405 s

Moving to @swc/jest and updating to jest@30:

Time:        1.212 s

Motivation and Context

Much faster test execution

How Has This Been Tested?

Running the test suite, confirming the same number of tests ran, the same number passed, and the execution time was significantly less.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

jake-danton and others added 4 commits August 5, 2025 07:57
Reasons:
* Allows update to latest `jest`
* Cut test run time in half

Before:
```
Test Suites: 34 passed, 34 total
Tests:       669 passed, 669 total
Snapshots:   0 total
Time:        3.742 s
```

after:
```
Test Suites: 34 passed, 34 total
Tests:       669 passed, 669 total
Snapshots:   0 total
Time:        1.277 s, estimated 3 s
```
@KKonstantinov
Copy link
Contributor

Would like to compare this to and consider https://github.com/vitest-dev/vitest (which is very easy to switch to from jest) while we're at it. Jest appears to be very slow to be updated against new Node features in the last years, which is also kind of shown by the need of this PR in the first place.

@jake-danton
Copy link
Author

Would like to compare this to and consider https://github.com/vitest-dev/vitest (which is very easy to switch to from jest) while we're at it. Jest appears to be very slow to be updated against new Node features in the last years, which is also kind of shown by the need of this PR in the first place.

I am happy to do that as I already migrated the @enth/mcp-sdk fork over to Vitest for the added speed and built in benchmarks and code coverage.

@jake-danton
Copy link
Author

@KKonstantinov I think we should also discuss moving tests into a dedicated test folder instead of in src and at the same time, move examples (which are currently exported as part of the package), integration-tests, __mocks__, and anything else not meant for export.

@KKonstantinov
Copy link
Contributor

KKonstantinov commented Oct 8, 2025

Agree. I'd also say currently there's no place to put shared test helpers.

By moving to a dedicated folder, there will be a better structure to have these reusable.

Examples are simple helper methods to create in-memory server + client and connect them. Such currently live inside .test.ts files and there are duplications.

Going off on a tangent here but:
Test coverage isn't currently a thing in this repository either.

IMHO for a protocol with such importance, I'd like to see which lines we are using on production without a single test. 😅🫠

Happy to contribute to this as well if it gets attention.

cc @ihrpr @pcarleton @cliffhall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants