-
Notifications
You must be signed in to change notification settings - Fork 23
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
test: Use node.js test runner #747
base: main
Are you sure you want to change the base?
Conversation
5fb117f
to
5ab449d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very interesting. Are we actually going to merge this? Given the "experimental" nature of it (and all the lint rules we have to disable), I don't see any reason to. What's your thinking?
|
||
describe('index', () => { | ||
let db: Db; | ||
let db: Omit<Db, 'collection' | 'collections' | 'command' | 'createCollection'> & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth making an extra Mock
utility type that does this for us? i.e. takes an object and re-types its properties as mocked versions?
I am actually planning to merge this PR soon-ish TBH. Given that the test runner feature is marked as Stable in node.js v22, we should be safe for the future. There will only be improvements in the future for this feature. It's a pretty decent feature IMHO, for a native feature baked into the language itself. I agree that the experimental module mocking is the only part that is standing out. I'm fairly certain that it will improve & get to a stable point in the next node.js versions. Yes, the code to achieve module mocking looks weird, but to its defense, whatever jest has for supporting ESM modules & mocking would look very similar to what we had do here. PS: The lint rules I disabled were mostly warnings about types. I'm hopeful that types will get improved soon for the module mocks. |
5ab449d
to
32e3ae0
Compare
I was interested to see how far we can get with replacing
jest
with the new native test runner in Node.js v20.AFAICT The main blocker now is the fact that we can't mock ESM imports.The blocker regarding mocking modules was addressed in Node.js v22 with experimental support for module mocking.
I've rewritten all our tests using the native Node.js test runner & assert package.