Skip to content

Commit 31b2601

Browse files
✅ create the lifecycle in setupViewTest
1 parent 76f7b3d commit 31b2601

2 files changed

Lines changed: 67 additions & 110 deletions

File tree

packages/rum-core/src/domain/view/setupViewTest.specHelper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Observable, deepClone } from '@datadog/browser-core'
22
import { registerCleanupTask } from '../../../../core/test'
33
import { mockRumConfiguration, setupLocationObserver } from '../../../test'
4-
import type { LifeCycle } from '../lifeCycle'
5-
import { LifeCycleEventType } from '../lifeCycle'
4+
import { LifeCycle, LifeCycleEventType } from '../lifeCycle'
65
import type { RumConfiguration } from '../configuration'
76
import type { RumMutationRecord } from '../../browser/domMutationObservable'
87
import type { ViewCreatedEvent, ViewEvent, ViewOptions, ViewEndedEvent } from './trackViews'
@@ -11,15 +10,15 @@ import { trackViews } from './trackViews'
1110
export type ViewTest = ReturnType<typeof setupViewTest>
1211

1312
interface ViewTrackingContext {
14-
lifeCycle: LifeCycle
1513
initialLocation?: string
1614
partialConfig?: Partial<RumConfiguration>
1715
}
1816

1917
export function setupViewTest(
20-
{ lifeCycle, initialLocation, partialConfig }: ViewTrackingContext,
18+
{ initialLocation, partialConfig }: ViewTrackingContext = {},
2119
initialViewOptions?: ViewOptions
2220
) {
21+
const lifeCycle = new LifeCycle()
2322
const domMutationObservable = new Observable<RumMutationRecord[]>()
2423
const windowOpenObservable = new Observable<void>()
2524
const configuration = mockRumConfiguration(partialConfig)
@@ -61,6 +60,7 @@ export function setupViewTest(
6160
registerCleanupTask(stop)
6261

6362
return {
63+
lifeCycle,
6464
startView,
6565
setViewContext,
6666
setViewContextProperty,

0 commit comments

Comments
 (0)