firebase / firebase/firebase-admin-node

'@firebase/database-compat/standalone' import error in jest tests

未关闭
#2,091 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: database
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

Environment

* Operating System version: MacOS 12.6.3
* Firebase SDK version: 11.3.0
* Firebase Product: firebase-admin
* Node.js version: 16.19.0
* NPM version: 8.19.3
* jest: 29.4.3
* typescript: 4.9.3

Describe the problem
After updating:
`firebase-functions` v3 -> v4
`firebase-admin` v11.3 -> v11.5
`firebase-functions-test` v0.3.0 -> v3.0.0

Any jest test using any firebase library will fail with the following error:
```
● Test suite failed to run

Cannot find module '@firebase/database-compat/standalone' from '../../node_modules/firebase-admin/lib/database/index.js'

Require stack:
/Users/igor/Dev/vogel_database/node_modules/firebase-admin/lib/database/index.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/common/providers/database.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/v1/providers/database.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/v1/index.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/v1.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/main.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/features.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/index.js
path/to/the/test/file.test.ts
```

Call stack in the example above may differ depending on the firebase library used, but will alway end at `Users/igor/Dev/vogel_database/node_modules/firebase-admin/lib/database/index.js` with the same error for importing `'@firebase/database-compat/standalone'`.

#### Steps to reproduce:

Install libraries with the provided versions.
Run `jest ` where test file uses at least one firebase library that has an internal reference to `firebase-admin`.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。