-
Notifications
You must be signed in to change notification settings - Fork 165
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 for GTM #425
Comments
I think I'll try this |
There are 2 GTMs, we need only one right? @mazipan @resir014 , Sorry I am not yet familiar/understand with noscript https://github.com/kawalcovid19/wargabantuwarga.com/blob/main/pages/_document.tsx#L19 https://github.com/kawalcovid19/wargabantuwarga.com/blob/main/pages/_app.tsx#L122 and the test is already there https://github.com/kawalcovid19/wargabantuwarga.com/blob/main/lib/__tests__/gtm.test.ts |
But the test is calling the function directly. |
Ahh, I see, how about the noscript @mazipan ? is still need in _document.tsx there? |
Yes, it's part of the snippet code from GTM. Can we assert the noscript also? |
If this can not be addressed in Unit Testing, then we need to utilize our E2E test on Cypress to check the existence of GTM script. |
Got it, investigating right now |
Not only that, I think we should also assert that the script is actually calling the GA endpoints correctly. Recently we realized that our Content Security Policy blocked GA requests. We can intercept the API requests using Cypress' routeHandler feature. I have been doing it for testing GA events in Ninja Van's website since a few years ago. 😁 |
So I just tried to test _document.tsx, Any experience for testing that file? @zainfathoni @mazipan tried https://stackoverflow.com/questions/67629091/how-to-test-document-in-next-using-jest cannot use the simple render function in rtl |
Description
Improvement for #419, we need to setup a proper test so we can avoid this accident in the future
The text was updated successfully, but these errors were encountered: