admin管理员组文章数量:1391975
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
本文标签:
版权声明:本文标题:angular - "ReferenceError: fetch is not defined", when Jest test imports Firesbase library - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744710760a2621114.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论