Commit 8dd6743
ref(tests): Refactor Node integration tests further. (#5596)
It seems that whenever a manual `http` request is initiated from a test (or test server) without waiting for / asserting on events or transactions, there are also transactions as side effects which may or may not finish before the test ends. This specifically happens with tests that assert request headers for `trace` and `baggage`, because they don't need to wait for the request / scenario to finish.
So it looks like the leakage to the next test doesn't come from the `nock` interceptor or an unclosed server, it comes from an unflushed Sentry transaction. The other tests using `getEnvelopeRequest` or `getMultipleEnvelopeRequest` finish wait for the events to be flushed.
While debugging this, I also made some more refactors in utilities, which I think will make them more concise.
Summary:
- [x] Making sure the events are flushed before tests that use `getAPIResponse` or `runScenario` complete.
- [x] Converted `http` usages in helpers to `axios` calls for simplicity and debuggability.
- [x] Moved `nock` initialization out of `runServer` so we don't need to carry `nock.Scope` around anymore. The `nock` instance is either manually initialized, or inside the `getMultipleEnvelopeRequest` function. The tests that are using manual `http` calls don't normally need nock anyways.
- [x] Filtering envelopes by their types on `nock` level, so if there is a need to filter them, we don't lose the expected `count`. Also, that makes the envelope indices inside tests simpler.
- [x] Switched to `nock.cleanAll()` and `nock.removeInterceptor(mock)` to end `nock` instead of `.persist(false)`.
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>1 parent dbbe0bd commit 8dd6743
File tree
48 files changed
+246
-249
lines changed- packages
- node-integration-tests
- suites
- express
- handle-error
- sentry-trace
- baggage-header-assign
- baggage-header-out-bad-tx-name
- baggage-header-out
- baggage-other-vendors-with-sentry-entries
- baggage-other-vendors
- baggage-transaction-name
- trace-header-assign
- trace-header-out
- tracing
- public-api
- addBreadcrumb
- empty-obj
- multiple_breadcrumbs
- simple_breadcrumb
- captureException
- catched-error
- empty-obj
- simple-error
- captureMessage
- simple_message
- with_level
- configureScope/set_properties
- setContext
- multiple-contexts
- non-serializable-context
- simple-context
- setExtras
- consecutive-calls
- multiple-extras
- setExtra
- multiple-extras
- non-serializable-extra
- simple-extra
- setTags/with-primitives
- setTag/with-primitives
- setUser
- unset_user
- update_user
- startTransaction
- basic-usage
- with-nested-spans
- withScope/nested-scopes
- sessions
- crashed-session-aggregate
- errored-session-aggregate
- exited-session-aggregate
- tracing
- apollo-graphql
- auto-instrument
- mongodb
- mysql
- pg
- prisma-orm
- tracePropagationTargets
- utils
- remix/test/integration/test/server
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
48 files changed
+246
-249
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | | - | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out-bad-tx-name/test.ts
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
0 commit comments