MCPcopy
hub / github.com/angular/angular / beforeEach

Function beforeEach

adev/src/app/editor/preview/preview.component.spec.ts:22–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20describe('Preview', () => {
21 // Before each is used as a callable function to prevent conflicts between tests
22 const beforeEach = () => {
23 const PREVIEW_URL = 'https://angular.dev/';
24
25 const fakeNodeRuntimeSandbox: Partial<NodeRuntimeSandbox> = {
26 previewUrl$: of(PREVIEW_URL),
27 };
28
29 const fakeNodeRuntimeState = {
30 loadingStep: signal(LoadingStep.NOT_STARTED),
31 error: signal<NodeRuntimeError | undefined>(undefined),
32 };
33
34 TestBed.configureTestingModule({
35 imports: [Preview],
36 providers: [
37 {
38 provide: NodeRuntimeSandbox,
39 useValue: fakeNodeRuntimeSandbox,
40 },
41 {
42 provide: NodeRuntimeState,
43 useValue: fakeNodeRuntimeState,
44 },
45 ],
46 });
47
48 const fixture = TestBed.createComponent(Preview);
49
50 const component = fixture.componentInstance;
51 const iframeElement = fixture.debugElement.query(By.css('iframe'));
52
53 return {
54 fixture,
55 component,
56 iframeElement,
57 PREVIEW_URL,
58 fakeNodeRuntimeState,
59 fakeNodeRuntimeSandbox,
60 getLoadingElementsWrapper: () =>
61 fixture.debugElement.query(By.css('adev-embedded-editor-preview-loading')),
62 };
63 };
64
65 it('should set iframe src', async () => {
66 const {fixture, PREVIEW_URL} = beforeEach();

Callers 15

hydration_spec.tsFile · 0.85
meta_spec.tsFile · 0.85
bootstrap_spec.tsFile · 0.85
title_spec.tsFile · 0.85
tools_spec.tsFile · 0.85
shadow_dom_spec.tsFile · 0.85

Calls 5

signalFunction · 0.90
cssMethod · 0.80
createComponentMethod · 0.65
queryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…