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 3c4673f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 9 additions & 4 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,12 +271,11 @@ async function setUpTest(browserLogsManager: BrowserLogsManager, { baseUrl, page
await waitForServersIdle()
}

async function tearDownTest({ intakeRegistry, withBrowserLogs, flushEvents, deleteAllCookies }: TestContext) {
await flushEvents()
await deleteAllCookies()
function tearDownPassedTest({ intakeRegistry, withBrowserLogs }: TestContext) {
console.log('Teardown test')

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

Expand All @@ -285,3 +285,8 @@ async function tearDownTest({ intakeRegistry, withBrowserLogs, flushEvents, dele
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 3c4673f

Please sign in to comment.