-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Testing and discord.js #275
Comments
Tests in the main Discord.js package are not automated unit tests. They are manually verified and require connecting to the gateway. With the exception of that cancelled CR and a whole mock server package. @discordjs/rest and @discordjs/ws do have them, but the latter is not employed yet. Sapphire framework has few tests as well. |
For REST requests, undici has a native MockAgent because it does not depend on Node.js' HTTP stack. nock can mock parts of this HTTP stack for use with other libraries (node-fetch, got, etc.) but I don't believe it works with HTTP/2. |
See nock/nock#1625 and nock/nock#1625 |
This research applies to Emcee too.
I'm not satisfied with the approach to unit tests right now and how we are doing mocking. Relevant links for now:
From 2021:
Example of unit tests from a Discord.js core dev
https://github.com/skyra-project/skyra/blob/refactor/switch-to-v13/tests/mocks/MockInstances.ts
https://github.com/skyra-project/skyra/blob/main/tests/lib/database/settings/structures/PermissionNodeManager.test.ts
https://github.com/discordjs/discord.js-modules/blob/main/packages/rest/__tests__/RequestHandler.test.ts another one with lower level mocking at nock/msw
2023:
https://github.com/cordejs/corde integration test with a second test bot, but not updated to recent discord.js. We can easily just implement this ourselves. Only works for messages anyway because Discord does not allow bots to send application commands.
discordjs/discord.js#7693 some other Discord.js dev test
discordjs/discord.js#6179 discussion on testing. One sample with a massive amount of mocking.
https://github.com/cherryblossom000/discord.js-mock somebody's attempt in that discussion to create a mocking library, abandoned, only useful for reference if anything
The text was updated successfully, but these errors were encountered: