-
Notifications
You must be signed in to change notification settings - Fork 142
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
How to mock in e2e testing #1017
Comments
How do you initialize segment: can you share that code? |
For sure. Some code is removed from here, but it's the general idea:
|
@brianabaker It sounds like From a testing pyramid perspective, I would generally recommend that you stick to using If you are determined to test our library in Cypress, I would recommend using Cypress HTTP request interception if you need that level of e2e-'ness' -- our Playwright example (see |
@silesky Okay, thank you! |
Hello! We're moving off of Segment analytics loaded in our window to this analytics-next library.
For Analytics testing, we do mostly RTL unit testing & also e2e testing with Cypress (e2e only for certain flows). I'm running into some issues modifying our Cypress mocks.
I'm not sure how to mock Segment to consider itself "initialized" like we used to when the code was on our window. I can see the mocked analytics when my code first loads (via console logs), but then they are overwritten (I think when Segment initializes).
This is how we used to mock, is there something i can do to replicate setting
window.analytics.initialize
to true?Thanks!
The text was updated successfully, but these errors were encountered: