Skip to content

Commit 4991bc9

Browse files
committed
add network generator test
1 parent 8c5c897 commit 4991bc9

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/signals/signals/src/core/signal-generators/network-gen/__tests__/network-generator.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ describe(NetworkGenerator, () => {
7777

7878
unregister()
7979
})
80-
80+
const networkSignalMatcher = {
81+
data: { requestId: expect.stringMatching(/.+/) },
82+
}
8183
it('should register and emit signals on fetch requests and responses if on same domain', async () => {
8284
const mockEmitter = { emit: jest.fn() }
8385
const networkGenerator = new TestNetworkGenerator()
@@ -95,7 +97,9 @@ describe(NetworkGenerator, () => {
9597
expect(mockEmitter.emit.mock.calls.length).toBe(2)
9698
const [first, second] = mockEmitter.emit.mock.calls
9799

98-
expect(first[0]).toMatchInlineSnapshot(`
100+
expect(first[0]).toMatchInlineSnapshot(
101+
networkSignalMatcher,
102+
`
99103
{
100104
"anonymousId": "",
101105
"context": {
@@ -121,16 +125,19 @@ describe(NetworkGenerator, () => {
121125
"title": "",
122126
"url": "http://localhost/",
123127
},
124-
"requestId": "cetsvycymt",
128+
"requestId": StringMatching /\\.\\+/,
125129
"url": "http://localhost/test",
126130
},
127131
"index": undefined,
128132
"timestamp": <ISO Timestamp>,
129133
"type": "network",
130134
}
131-
`)
135+
`
136+
)
132137

133-
expect(second[0]).toMatchInlineSnapshot(`
138+
expect(second[0]).toMatchInlineSnapshot(
139+
networkSignalMatcher,
140+
`
134141
{
135142
"anonymousId": "",
136143
"context": {
@@ -156,15 +163,16 @@ describe(NetworkGenerator, () => {
156163
"title": "",
157164
"url": "http://localhost/",
158165
},
159-
"requestId": "cetsvycymt",
166+
"requestId": StringMatching /\\.\\+/,
160167
"status": 200,
161168
"url": "http://localhost/test",
162169
},
163170
"index": undefined,
164171
"timestamp": <ISO Timestamp>,
165172
"type": "network",
166173
}
167-
`)
174+
`
175+
)
168176

169177
unregister()
170178
})

0 commit comments

Comments
 (0)