[Idea] Allow `track` to run in test environment, by default
mrjonesbot opened this issue · comments
Hi @ankane , loving the gem so far.
I noticed when running my test suite - and attempting to assert certain events were created - that Ahoy was marking each request as a bot and skipping through the track
method.
I added this line to Ahoy::Store
to make sure track
is not skipped in my test suite:
However, I'm wondering if this is intended and if so, what are the reasons?
Trying to avoid unforeseen consequences.
As an aside, do you have any recommendations for tying JWT authentication to visits?
@mrjonesbot I have just encountered the same issue on our project. I'd recommend the following alternative:
Ahoy.track_bots = Rails.env.test?
Hey @mrjonesbot, I can't recall if it was intentional, but it's been that way for a while. I agree it's a bit surprising, so I've added it to ideas to consider for the next major version (#495). In the meantime, @peterdavidhamilton's solution is the recommended way to do it.