Skip to content
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

Open
Tracked by #688
mazipan opened this issue Jul 25, 2021 · 9 comments
Open
Tracked by #688

Testing for GTM #425

mazipan opened this issue Jul 25, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request hacktoberfest Issues for Hacktoberfest testing Automated testing

Comments

@mazipan
Copy link
Member

mazipan commented Jul 25, 2021

Description

Improvement for #419, we need to setup a proper test so we can avoid this accident in the future

@rubiagatra
Copy link
Collaborator

I think I'll try this

@rubiagatra
Copy link
Collaborator

rubiagatra commented Aug 15, 2021

@mazipan
Copy link
Member Author

mazipan commented Aug 15, 2021

But the test is calling the function directly.
I think it's better if we render some pages, and make sure we have GTM script in the page.

@rubiagatra
Copy link
Collaborator

rubiagatra commented Aug 15, 2021

Ahh, I see, how about the noscript @mazipan ? is still need in _document.tsx there?

@mazipan
Copy link
Member Author

mazipan commented Aug 15, 2021

Yes, it's part of the snippet code from GTM.

Can we assert the noscript also?

@mazipan
Copy link
Member Author

mazipan commented Aug 15, 2021

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.

@rubiagatra
Copy link
Collaborator

Got it, investigating right now

@zainfathoni
Copy link
Member

zainfathoni commented Aug 15, 2021

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. 😁

@rubiagatra rubiagatra self-assigned this Aug 15, 2021
@zainfathoni zainfathoni removed their assignment Aug 21, 2021
@rubiagatra
Copy link
Collaborator

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 render(<MyDocument />)

@zainfathoni zainfathoni added the hacktoberfest Issues for Hacktoberfest label Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Issues for Hacktoberfest testing Automated testing
Projects
None yet
Development

No branches or pull requests

4 participants