@@ -153,6 +153,7 @@ describe('internal api', () => {
153153 } ) ;
154154
155155 it ( 'resolves with a dummy token and an error if failed to get a token' , async ( ) => {
156+ const errorStub = stub ( console , 'error' ) ;
156157 const appCheck = initializeAppCheck ( app , {
157158 provider : new ReCaptchaV3Provider ( FAKE_SITE_KEY )
158159 } ) ;
@@ -162,16 +163,21 @@ describe('internal api', () => {
162163 const error = new Error ( 'oops, something went wrong' ) ;
163164 stub ( client , 'exchangeToken' ) . returns ( Promise . reject ( error ) ) ;
164165
165- const token = await getToken ( appCheck as AppCheckService ) ;
166+ const token = await getToken ( appCheck as AppCheckService , false , true ) ;
166167
167168 expect ( reCAPTCHASpy ) . to . be . called ;
168169 expect ( token ) . to . deep . equal ( {
169170 token : formatDummyToken ( defaultTokenErrorData ) ,
170171 error
171172 } ) ;
173+ expect ( errorStub . args [ 0 ] [ 1 ] . message ) . to . include (
174+ 'oops, something went wrong'
175+ ) ;
176+ errorStub . restore ( ) ;
172177 } ) ;
173178
174179 it ( 'resolves with a dummy token and an error if failed to get a token in debug mode' , async ( ) => {
180+ const errorStub = stub ( console , 'error' ) ;
175181 window . FIREBASE_APPCHECK_DEBUG_TOKEN = true ;
176182 const appCheck = initializeAppCheck ( app , {
177183 provider : new ReCaptchaV3Provider ( FAKE_SITE_KEY )
@@ -180,28 +186,37 @@ describe('internal api', () => {
180186 const error = new Error ( 'oops, something went wrong' ) ;
181187 stub ( client , 'exchangeToken' ) . returns ( Promise . reject ( error ) ) ;
182188
183- const token = await getToken ( appCheck as AppCheckService ) ;
189+ const token = await getToken ( appCheck as AppCheckService , false , true ) ;
184190
185191 expect ( token ) . to . deep . equal ( {
186192 token : formatDummyToken ( defaultTokenErrorData ) ,
187193 error
188194 } ) ;
195+ expect ( errorStub . args [ 0 ] [ 1 ] . message ) . to . include (
196+ 'oops, something went wrong'
197+ ) ;
189198 delete window . FIREBASE_APPCHECK_DEBUG_TOKEN ;
199+ errorStub . restore ( ) ;
190200 } ) ;
191201
192202 it ( 'resolves with a dummy token and an error if recaptcha failed' , async ( ) => {
203+ const errorStub = stub ( console , 'error' ) ;
193204 const appCheck = initializeAppCheck ( app , {
194205 provider : new ReCaptchaV3Provider ( FAKE_SITE_KEY )
195206 } ) ;
196207
197208 const reCAPTCHASpy = stubGetRecaptchaToken ( '' , false ) ;
198209 const exchangeTokenStub = stub ( client , 'exchangeToken' ) ;
199210
200- const token = await getToken ( appCheck as AppCheckService ) ;
211+ const token = await getToken ( appCheck as AppCheckService , false , true ) ;
201212
202213 expect ( reCAPTCHASpy ) . to . be . called ;
203214 expect ( exchangeTokenStub ) . to . not . be . called ;
204215 expect ( token . token ) . to . equal ( formatDummyToken ( defaultTokenErrorData ) ) ;
216+ expect ( errorStub . args [ 0 ] [ 1 ] . message ) . to . include (
217+ AppCheckError . RECAPTCHA_ERROR
218+ ) ;
219+ errorStub . restore ( ) ;
205220 } ) ;
206221
207222 it ( 'notifies listeners using cached token' , async ( ) => {
0 commit comments