11import { ParentChildModule } from './components/parent-child.module'
22import { ParentComponent } from './components/parent.component'
33import { CounterComponent } from './components/counter.component'
4- import { CounterService } from './components/counter.service'
54import { ChildComponent } from './components/child.component'
65import { WithDirectivesComponent } from './components/with-directives.component'
76import { ButtonOutputComponent } from './components/button-output.component'
@@ -10,8 +9,6 @@ import { EventEmitter, Component } from '@angular/core'
109import { ProjectionComponent } from './components/projection.component'
1110import { ChildProvidersComponent } from './components/child-providers.component'
1211import { ParentProvidersComponent } from './components/parent-providers.component'
13- import { HttpClientModule } from '@angular/common/http'
14- import { of } from 'rxjs'
1512import { ChildProvidersService } from './components/child-providers.service'
1613import { AnotherChildProvidersComponent } from './components/another-child-providers.component'
1714import { TestBed } from '@angular/core/testing'
@@ -28,7 +25,7 @@ import { UrlImageComponent } from './components/url-image.component'
2825} )
2926class WrapperComponent { }
3027
31- // Staring with Angular v19, standalone = true is the new default behavior.
28+ // Starting with Angular v19, standalone = true is the new default behavior.
3229// This means that the ng module configurations, including test module configurations,
3330// do not work by default with components. Cypress for non standalone components
3431// injects the CommonModule by default and allows users to add module declarations.
@@ -58,7 +55,7 @@ describe('angular mount', () => {
5855 } )
5956
6057 it ( 'accepts providers' , ( ) => {
61- cy . mount ( CounterComponent , { providers : [ CounterService ] } )
58+ cy . mount ( CounterComponent )
6259 cy . contains ( 'button' , 'Increment: 0' ) . click ( ) . contains ( 'Increment: 1' )
6360 } )
6461
@@ -203,7 +200,6 @@ describe('angular mount', () => {
203200 } )
204201
205202 cy . mount ( ChildProvidersComponent , {
206- imports : [ HttpClientModule ] ,
207203 providers : [ ChildProvidersService ] ,
208204 } )
209205
@@ -220,7 +216,6 @@ describe('angular mount', () => {
220216
221217 cy . mount ( ParentProvidersComponent , {
222218 declarations : [ ChildProvidersComponent , AnotherChildProvidersComponent ] ,
223- imports : [ HttpClientModule ] ,
224219 providers : [ ChildProvidersService ] ,
225220 } )
226221
@@ -231,13 +226,12 @@ describe('angular mount', () => {
231226 it ( 'can make test doubles for child components' , ( ) => {
232227 cy . mount ( ParentProvidersComponent , {
233228 declarations : [ ChildProvidersComponent , AnotherChildProvidersComponent ] ,
234- imports : [ HttpClientModule ] ,
235229 providers : [
236230 {
237231 provide : ChildProvidersService ,
238232 useValue : {
239- getMessage ( ) {
240- return of ( 'test' )
233+ async getMessage ( ) : Promise < string > {
234+ return 'test'
241235 } ,
242236 } as ChildProvidersService ,
243237 } ,
@@ -257,7 +251,6 @@ describe('angular mount', () => {
257251 } )
258252
259253 cy . mount ( AnotherChildProvidersComponent , {
260- imports : [ HttpClientModule ] ,
261254 providers : [ ChildProvidersService ] ,
262255 } )
263256
@@ -266,12 +259,12 @@ describe('angular mount', () => {
266259 } )
267260
268261 it ( 'can use a test double for a component with a provider override' , ( ) => {
269- cy . mount ( AnotherChildProvidersComponent , { imports : [ HttpClientModule ] } )
262+ cy . mount ( AnotherChildProvidersComponent )
270263 TestBed . overrideComponent ( AnotherChildProvidersComponent , { add : { providers : [ {
271264 provide : ChildProvidersService ,
272265 useValue : {
273- getMessage ( ) {
274- return of ( 'test' )
266+ async getMessage ( ) : Promise < string > {
267+ return 'test'
275268 } ,
276269 } ,
277270 } ] } } )
@@ -290,7 +283,6 @@ describe('angular mount', () => {
290283
291284 cy . mount ( ParentProvidersComponent , {
292285 declarations : [ ChildProvidersComponent , AnotherChildProvidersComponent ] ,
293- imports : [ HttpClientModule ] ,
294286 providers : [ ChildProvidersService ] ,
295287 } )
296288
@@ -301,15 +293,14 @@ describe('angular mount', () => {
301293 it ( 'can use a test double for a child component with a provider override' , ( ) => {
302294 TestBed . overrideProvider ( ChildProvidersService , {
303295 useValue : {
304- getMessage ( ) {
305- return of ( 'test' )
296+ async getMessage ( ) : Promise < string > {
297+ return 'test'
306298 } ,
307299 } as ChildProvidersService ,
308300 } )
309301
310302 cy . mount ( ParentProvidersComponent , {
311303 declarations : [ ChildProvidersComponent , AnotherChildProvidersComponent ] ,
312- imports : [ HttpClientModule ] ,
313304 } )
314305
315306 cy . get ( 'button' ) . contains ( 'default another child message' ) . click ( )
0 commit comments