I have monorepo, which contains Angular applications and libraries. On of the library contains an Angular FirestoreService to access Firestore database. The application, when started, works by design. On the other hand, any Jest test, which implicitly refers to FirestoreService fails with:
Test suite failed to run
ReferenceError: fetch is not defined
1 | import { inject, Inject } from '@angular/core';
2 | import { FirestoreDoc } from './firestore-doc';
> 3 | import { collection, Firestore, getDocs, limit, query } from '@angular/fire/firestore';
| ^
4 |
5 | @Inject({ providedIn: 'root' })
6 | export class FirestoreService {
at Object.<anonymous> (../../node_modules/firebase/node_modules/@firebase/auth/src/platform_node/index.ts:33:26)
at Object.<anonymous> (../../node_modules/firebase/node_modules/@firebase/auth/dist/node/index.js:5:12)
at Object.<anonymous> (../../node_modules/firebase/auth/dist/index.cjs.js:5:12)
at Object.<anonymous> (../../node_modules/rxfire/auth/index.cjs.js:5:12)
at Object.<anonymous> (../../node_modules/@angular/fire/fesm2022/angular-fire-auth.mjs:9:80)
at Object.<anonymous> (../../node_modules/@angular/fire/fesm2022/angular-fire-firestore.mjs:8:31)
at Object.<anonymous> (../../libs/firestore/src/lib/firestore/firestore.service.ts:3:1)
at Object.<anonymous> (../../libs/firestore/src/index.ts:1:1)
at Object.<anonymous> (src/app/nx-welcomeponent.ts:3:1)
at Object.<anonymous> (src/app/nx-wellcomeponent.spec.ts:2:1)
To be able to reproduce the issue, I created a skeleton project, only with the key elements of this problem. See: If you want to start the application, see: .json#L5
To verify the issue, just run the unit test: ponent.spec.ts
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744710760a4589328.html
评论列表(0条)