Skip to content

Commit

Permalink
👌 split tearDown test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-lebeau committed Jan 31, 2025
1 parent 0faa9fc commit 2df1d26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 7 additions & 9 deletions test/e2e/lib/framework/createTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ function declareTest(title: string, setupOptions: SetupOptions, factory: SetupFa

try {
await runner(testContext)
tearDownPassedTest(testContext)
} finally {
await tearDownTest(testContext)
}
Expand Down Expand Up @@ -270,18 +271,15 @@ async function setUpTest(browserLogsManager: BrowserLogsManager, { baseUrl, page
await waitForServersIdle()
}

async function tearDownTest({ intakeRegistry, withBrowserLogs, flushEvents, deleteAllCookies }: TestContext) {
await flushEvents()
await deleteAllCookies()

if (test.info().expectedStatus === 'skipped') {
// ignore following expectations if test was skipped
return
}

function tearDownPassedTest({ intakeRegistry, withBrowserLogs }: TestContext) {
expect(intakeRegistry.telemetryErrorEvents).toHaveLength(0)
validateRumFormat(intakeRegistry.rumEvents)
withBrowserLogs((logs) => {
expect(logs.filter((log) => log.level === 'error')).toHaveLength(0)
})
}

async function tearDownTest({ flushEvents, deleteAllCookies }: TestContext) {
await flushEvents()
await deleteAllCookies()
}
2 changes: 0 additions & 2 deletions test/e2e/scenario/rum/init.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ test.describe('API calls and events around init', () => {
;(window.DD_RUM! as unknown as { init(): void }).init()
})
.run(({ withBrowserLogs }) => {
expect([1, 2, 3]).toHaveLength(1)

withBrowserLogs((logs) => {
expect(logs).toHaveLength(1)
expect(logs[0].message).toEqual(expect.stringContaining('Datadog Browser SDK'))
Expand Down

0 comments on commit 2df1d26

Please sign in to comment.