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

Add assert log contains and log dump helpers #802

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Mar 2, 2023

These helpers should help us to better see the log output locally and on CI if the test fails. I constantly needed to dump log requests when testing #687. This helper automatically does that for us.

For example, if the following fails, we have no idea why it fails unless we dump the logs by hand:

assert.True(t, tb.logCache.contains("skipping request handling of data URL"))

Example output when we use the assertContains helper:

tb.logCache.assertContains(t, "skipping request handling of data URL")

=== RUN   TestURLSkipRequest
=== PAUSE TestURLSkipRequest
=== CONT  TestURLSkipRequest
    network_manager_test.go:26: expected log cache to contain "skipping request handling of data URL", but it didn't.
    network_manager_test.go:26: --------------------------------------------------------------------------------
    network_manager_test.go:26: wsURL:"ws://127.0.0.1:57218/devtools/browser/6e48a690-4676-4b99-9efe-8223a3d91cda"
    ...
    network_manager_test.go:26: sid:71D7211C20290E9E84D3E61C20BA2C6E tid:F077AC9457875E49FE074C9D8F7F1619 method:"Page.enable"
    network_manager_test.go:26: sid:71D7211C20290E9E84D3E61C20BA2C6E tid:F077AC9457875E49FE074C9D8F7F1619
    network_manager_test.go:26: sid:71D7211C20290E9E84D3E61C20BA2C6E tid:F077AC9457875E49FE074C9D8F7F1619 method:"Page.enable"
    network_manager_test.go:26: SUPPOSED TO BE HERE!
    network_manager_test.go:26: sid:71D7211C20290E9E84D3E61C20BA2C6E tid:F077AC9457875E49FE074C9D8F7F1619 method:"Page.getFrameTree"
    ...

@inancgumus inancgumus force-pushed the add/687-assert-log-contains branch 2 times, most recently from 65fec61 to da43ace Compare March 2, 2023 08:59
@inancgumus inancgumus added tests dx developer experience labels Mar 2, 2023
@inancgumus inancgumus self-assigned this Mar 2, 2023
@inancgumus inancgumus added this to the v0.9.0 milestone Mar 2, 2023
@inancgumus inancgumus requested review from ankur22 and ka3de March 2, 2023 09:02
@inancgumus inancgumus marked this pull request as ready for review March 2, 2023 09:02
This helps us to better see the log output locally and on CI if the test
fails.
@inancgumus inancgumus changed the title Add assert log contains helper Add assert log contains and log dump helpers Mar 2, 2023
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks useful, thanks for this!

Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
LGTM.

@inancgumus inancgumus merged commit 88606db into main Mar 2, 2023
@inancgumus inancgumus deleted the add/687-assert-log-contains branch March 2, 2023 11:21
@inancgumus inancgumus removed the dx developer experience label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants