Skip to content

feat(tests): more test helpers and features#1060

Merged
solnic merged 9 commits into
masterfrom
refa/simplify-tests-using-new-helpers
May 20, 2026
Merged

feat(tests): more test helpers and features#1060
solnic merged 9 commits into
masterfrom
refa/simplify-tests-using-new-helpers

Conversation

@solnic
Copy link
Copy Markdown
Collaborator

@solnic solnic commented May 15, 2026

New options in Sentry.Test.setup_sentry/1

  • :telemetry_processor — keyword list forwarded to the per-test Sentry.TelemetryProcessor (e.g. buffer_configs, buffer_capacities, scheduler_weights, transport_capacity). Replaces the manual stop_supervised! + start_supervised! dance for tests that need a custom processor configuration.

  • :collect_envelopes — when set, wires up a Bypass envelope collector automatically and returns its reference under :ref:

    • true — collector with no filtering;
    • keyword list (e.g. [type: "check_in"]) — forwarded to setup_bypass_envelope_collector/2 to filter by envelope item type.

    Collapses the common setup_bypass(...) + setup_bypass_envelope_collector(bypass) two-step into a single call:

    setup do
      Sentry.Test.setup_sentry(collect_envelopes: true, traces_sample_rate: 1.0)
    end
    
    test "...", %{ref: ref} do
      # ...
    end

New test helpers in Sentry.Test.Assertions

  • assert_sentry_transaction(ref, criteria) — collects exactly 1 transaction envelope via ref and asserts it matches criteria. Returns the matched transaction. Reserved option: :timeout (default 1000ms).

  • find_sentry_transaction!(ref, criteria) — collects up to :count transaction envelopes via ref and returns the first one matching criteria. Raises if none match. Reserved options: :count (default 1), :timeout (default 1000ms).

  • refute_sentry_check_in(ref, timeout) — flushes the TelemetryProcessor pipeline, then asserts no check-in envelope arrives at the Bypass collector within timeout (default 100ms). Pair with Sentry.Test.setup_sentry(collect_envelopes: [type: "check_in"]).

Together they replace verbose usage like:

assert_sentry_report(collect_sentry_transactions(ref, 1), transaction: "...")
find_sentry_report!(collect_sentry_transactions(ref, 10, timeout: 2000), ...)

@solnic solnic force-pushed the feat/tests-support-async-tests-with-tp branch 4 times, most recently from 9f7c9b8 to d18a6d5 Compare May 18, 2026 10:39
@solnic solnic force-pushed the refa/simplify-tests-using-new-helpers branch from d9001f5 to ba832f2 Compare May 18, 2026 11:13
@solnic solnic marked this pull request as ready for review May 18, 2026 11:14
Base automatically changed from feat/tests-support-async-tests-with-tp to master May 20, 2026 11:50
@solnic solnic force-pushed the refa/simplify-tests-using-new-helpers branch from ba832f2 to c77bb92 Compare May 20, 2026 11:51
@solnic solnic force-pushed the refa/simplify-tests-using-new-helpers branch from c77bb92 to 6211c9f Compare May 20, 2026 11:58
@solnic solnic marked this pull request as draft May 20, 2026 12:07
@solnic solnic force-pushed the refa/simplify-tests-using-new-helpers branch from 6211c9f to aec18a5 Compare May 20, 2026 12:24
@solnic solnic marked this pull request as ready for review May 20, 2026 12:36
Comment thread lib/sentry/test/assertions.ex
@solnic solnic merged commit 479ba04 into master May 20, 2026
13 checks passed
@solnic solnic deleted the refa/simplify-tests-using-new-helpers branch May 20, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants