File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
projects/testing-library/tests/issues Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 5757 "@angular/compiler-cli" : " 17.1.0" ,
5858 "@angular/forms" : " 17.1.0" ,
5959 "@angular/language-service" : " 17.1.0" ,
60+ "@nx/eslint" : " 17.2.8" ,
6061 "@nx/eslint-plugin" : " 17.2.8" ,
6162 "@nx/jest" : " 17.2.8" ,
6263 "@nx/node" : " 17.2.8" ,
7778 "eslint-config-prettier" : " 9.0.0" ,
7879 "eslint-plugin-import" : " ~2.25.4" ,
7980 "eslint-plugin-jasmine" : " ~4.1.3" ,
81+ "eslint-plugin-jest" : " ^27.6.3" ,
8082 "eslint-plugin-jest-dom" : " ~4.0.1" ,
8183 "eslint-plugin-testing-library" : " ~5.0.1" ,
8284 "jasmine-core" : " 4.2.0" ,
102104 "semantic-release" : " ^18.0.0" ,
103105 "ts-jest" : " 29.1.0" ,
104106 "ts-node" : " 10.9.1" ,
105- "typescript" : " 5.2.2" ,
106- "@nx/eslint" : " 17.2.8"
107+ "typescript" : " 5.2.2"
107108 }
108109}
Original file line number Diff line number Diff line change 1+ import { CommonModule } from '@angular/common' ;
2+ import { BehaviorSubject } from 'rxjs' ;
3+ import { Component , Inject , Injectable } from '@angular/core' ;
4+ import { screen , render } from '../../src/public_api' ;
5+
6+ // Service
7+ @Injectable ( )
8+ class DemoService {
9+ buttonTitle = new BehaviorSubject < string > ( 'Click me' ) ;
10+ }
11+
12+ // Component
13+ @Component ( {
14+ selector : 'atl-issue-435' ,
15+ standalone : true ,
16+ imports : [ CommonModule ] ,
17+ providers : [ DemoService ] ,
18+ template : `
19+ <button>
20+ <!-- 👇 I only get the Inject error when I use the async pipe here -->
21+ {{ demoService.buttonTitle | async }}
22+ </button>
23+ ` ,
24+ } )
25+ class DemoComponent {
26+ constructor ( @Inject ( DemoService ) public demoService : DemoService ) { }
27+ }
28+
29+ // Test
30+ describe ( 'DemoComponent' , ( ) => {
31+ it ( 'should render button' , async ( ) => {
32+ await render ( DemoComponent ) ;
33+
34+ const button = screen . getByRole ( 'button' , {
35+ name : / C l i c k m e / ,
36+ } ) ;
37+
38+ expect ( button ) . toBeVisible ( ) ;
39+ } ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments