-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spike: migrate tests to Jest (ts-jest) #3159
Comments
Work started in https://github.com/strongloop/loopback-next/tree/test/jest |
I'm curious whether this spike has an updated timeline as you removed the 2020Q1 tag about a month ago. From my research, a lot of users have expressed mocha is faster than jest, but we're also running into some slowness when running 300+ tests over 50+ files. I'm curious whether the migration to Jest would prove beneficial and whether we should embark on that adventure by ourselves or hold off and wait for the official loopback merge. |
@mamiller93 this spike is not a priority for us in the next few months (at least). The migration would require too many changes. We are also discussing with @boneskull the option to improve Mocha to better serve our needs: allow the tests to be run in parallel, better support for TypeScript in watch mode.
I guess the only way how to answer the first question is to do a spike on your side and see if you can get any speed up by moving to Jest. Personally, I find Jest much better to use when working in test-driven way, as it has CLI UI allowing me to re-run only a subset of tests (e.g. only the tests that failed in the last run), update snapshots, etc. Having said that, I have only minimal experience with Jest, it's very likely I am not aware of many problems that we would discover if we migrated loopback-next to Jest. |
Alright, so the parallel mode is ready for testing by the LB team. Ref: mochajs/mocha#4198 Installation
Regarding Test Results
Notes
Please let me know if you're stuck, and I can help out. Also would like to know when the team can carve out some time to look at this, since landing the PR will depend on your requirements. Thanks! |
in my project im running loopback with just typescript (ts-node, ts-node-dev) i changed booters to .ts and run ts-node with --type-check flag, and im running jest with ts-jest with no problems (until now) |
With #5011 in place, we are going to stick with Mocha for the foreseeable future. |
Let's try to speed up our dev process and CI builds by migrating to ts-jest.
Known problems to resolve:
@loopback/metadata
relies oninstanceof Function
check that does not work under Jest, see fix(metadata): don't rely oninstanceof
checks #3160@loopback/boot
is not able to find & load artifacts from original.ts
filesReferenceError: Cannot access 'CustomerController' before initialization
.The key 'repositories.NoteRepository' is not bound to any value in context application
)See the list of skipped files in https://github.com/strongloop/loopback-next/blob/test/jest/jest.config.js for the up-to-date information.
The text was updated successfully, but these errors were encountered: