Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
zikaari committed Jan 29, 2024
1 parent a1012fb commit fc0be16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 6 additions & 5 deletions packages/browser-integration-tests/src/custom-global-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ test.describe('Segment with custom global key', () => {
test('supports using a custom global key', async ({ page }) => {
// Load analytics.js
await page.goto('/standalone-custom-key.html')
await page.evaluate(() =>
(window as any).segment_analytics.load('fake-key')
)
await page.evaluate(() => {
;(window as any).segment_analytics.track('track before load')
;(window as any).segment_analytics.load('fake-key')
})

const req = await page.waitForRequest('https://api.segment.io/v1/t')

// confirm that any events triggered from within snippet have been sent
expect(req.postDataJSON().event).toBe('track from snippet')
// confirm that any events triggered before load have been sent
expect(req.postDataJSON().event).toBe('track before load')

const contextObj = await page.evaluate(() =>
(window as any).segment_analytics.track('track after load')
Expand Down
3 changes: 0 additions & 3 deletions packages/browser-integration-tests/standalone-custom-key.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
analytics._writeKey = key
}
analytics.SNIPPET_VERSION = '5.2.0'

// will be used for asserting in the corresponding test
analytics.track('track from snippet')
}
})()
</script>
Expand Down

0 comments on commit fc0be16

Please sign in to comment.