File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,10 @@ function cleanupAtFixture(fixture: ComponentFixture<any>) {
492492
493493 if ( ! fixture . nativeElement . getAttribute ( 'ng-version' ) && fixture . nativeElement . parentNode === document . body ) {
494494 document . body . removeChild ( fixture . nativeElement ) ;
495+ } else if ( ! fixture . nativeElement . getAttribute ( 'id' ) && document . body . children ?. [ 0 ] === fixture . nativeElement ) {
496+ document . body . removeChild ( fixture . nativeElement ) ;
495497 }
498+
496499 mountedFixtures . delete ( fixture ) ;
497500}
498501
Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
2+ import { render , screen } from '../../src/public_api' ;
3+
4+ test ( 'should create the app' , async ( ) => {
5+ await render ( FixtureComponent ) ;
6+ expect ( screen . getByRole ( 'heading' ) ) . toBeInTheDocument ( ) ;
7+ } ) ;
8+
9+ test ( 'should re-create the app' , async ( ) => {
10+ await render ( FixtureComponent ) ;
11+ expect ( screen . getByRole ( 'heading' ) ) . toBeInTheDocument ( ) ;
12+ } ) ;
13+
14+ @Component ( {
15+ selector : 'atl-fixture' ,
16+ standalone : true ,
17+ template : '<h1>My title</h1>' ,
18+ // eslint-disable-next-line @angular-eslint/no-host-metadata-property
19+ host : {
20+ // eslint-disable-next-line @typescript-eslint/naming-convention
21+ '[attr.id]' : 'null' , // this breaks the cleaning up of tests
22+ } ,
23+ } )
24+ class FixtureComponent { }
You can’t perform that action at this time.
0 commit comments