Mtg on Nostr: @Johns Yes, that's an option. But in general, if it's possible to mock an external ...
@Johns
Yes, that's an option.
But in general, if it's possible to mock an external module locally, then that's better.
Actually, just today, I had a discussion with a few people on the nostr Telegram group regarding this thing, so I'll put here the reasons why I think an in-memory simple mock relay is better than hosting a real "testing" relay:
1- Simpler to run
When you are introducing an external component to your testing flow like a Relay,
you (or anyone else) won't be able to run your tests unless they also have a running relay on their machine.
2- Speed
A mock relay would just be a very simple class that holds a list of events objects in memory & returns them.
An actual relay will likely have many more functionalites that you likely don't need in a "web-app testing " environment.
3- Running it on a CI/CD environment
Like if you want to always run all your tests on your CI/CD after each push.
If your tests require an actual running relay, you need to host one yourself online
Even if it's considered a "testing" relay, it is still a new live component that needs updates, maintainence, and has costs.
So if we can get around that by using a mock relay, I'd prefer that.
(But that's in the case that it works eventually 🥲🥲)
Yes, that's an option.
But in general, if it's possible to mock an external module locally, then that's better.
Actually, just today, I had a discussion with a few people on the nostr Telegram group regarding this thing, so I'll put here the reasons why I think an in-memory simple mock relay is better than hosting a real "testing" relay:
1- Simpler to run
When you are introducing an external component to your testing flow like a Relay,
you (or anyone else) won't be able to run your tests unless they also have a running relay on their machine.
2- Speed
A mock relay would just be a very simple class that holds a list of events objects in memory & returns them.
An actual relay will likely have many more functionalites that you likely don't need in a "web-app testing " environment.
3- Running it on a CI/CD environment
Like if you want to always run all your tests on your CI/CD after each push.
If your tests require an actual running relay, you need to host one yourself online
Even if it's considered a "testing" relay, it is still a new live component that needs updates, maintainence, and has costs.
So if we can get around that by using a mock relay, I'd prefer that.
(But that's in the case that it works eventually 🥲🥲)