botblock / BotList

A package for easily updating your server count on all Discord bot lists. [JavaScript - maintained by @PassTheMayo]
https://www.npmjs.com/package/botlist
MIT License
10 stars 2 forks source link

Unit testing #1

Open jonahsnider opened 5 years ago

jonahsnider commented 5 years ago

You can relatively easily have unit testing for API requests by using libraries like Sinon. I created a package very similar to this and it had unit testing for nearly every request variation, with around 90% test coverage.

The test code is open source, here's an example file that uses moxios, sinon, and TAP for botlist.space.

PassTheMayo commented 5 years ago

This sounds great, but wouldn't this require a test bot to be submitted to each list? Having a bot listed in every list sounds like something that would be difficult to maintain. I'll be cleaning up the code some more this weekend, and doing some manual testing.

MattIPv4 commented 5 years ago

Just as food for thought on test lib, we use Mocha & Chai (chai-http) for testing BotBlock itself (web rendering & API).

jonahsnider commented 5 years ago

but wouldn't this require a test bot to be submitted to each list?

You misunderstood what I meant.

In your code, when you send a request to BotBlock, the request would be intercepted by a testing library (I used moxios) and allow you to compare the sent request to what should have been sent,.