gpt4 book ai didi

与 Jest 一起使用时 Firebase 模拟器泄漏

转载 作者:行者123 更新时间:2023-12-04 12:23:08 27 4
gpt4 key购买 nike

我正在使用 firebase 模拟器来运行我的笑话测试:
package.json:

{
"scripts": {
"test": "firebase emulators:exec --only firestore --project sample jest",
},
}
jest.config.json:
{
"preset": "ts-jest",
"testEnvironment": "node",
"modulePathIgnorePatterns": ["<rootDir>/lib/"]
}
当我运行时,我收到以下消息

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks.


--detectOpenHandles 一起运行我什么都没看到
npm test

> functions@ test /home/ubuntu/workspace/blinktrade/otc/firebase/functions
> firebase emulators:exec --only firestore --project sample 'jest --detectOpenHandles'

i emulators: Starting emulators: firestore
i firestore: Firestore Emulator logging to firestore-debug.log
i Running script: jest --detectOpenHandles
PASS tests/index.test.ts
● Console

console.warn
{"severity":"WARNING","message":"Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail"}

at write (node_modules/firebase-functions/lib/logger.js:39:78)
at Object.warn (node_modules/firebase-functions/lib/logger.js:90:5)
at Object.setup (node_modules/firebase-functions/lib/setup.js:46:22)
at Object.<anonymous> (node_modules/firebase-functions/lib/index.js:69:9)

console.log
{"_fieldsProto":{"kind":{"stringValue":"text"},"content":{"stringValue":"test"},"author":{"stringValue":"user1"},"room":{"stringValue":"room1"},"timestamp":{"timestampValue":{"seconds":1611687728,"nanos":749000000}}},"_ref":{"_firestore":{"_settings":{"projectId":"not-a-project","firebaseVersion":"9.4.2","libName":"gccl","libVersion":"4.8.1 fire/9.4.2","ssl":false,"servicePath":"localhost","port":8080},"_settingsFrozen":false,"_serializer":{"allowUndefined":false},"_projectId":"not-a-project","registeredListenersCount":0,"bulkWritersCount":0,"_backoffSettings":{"initialDelayMs":100,"maxDelayMs":60000,"backoffFactor":1.3},"_clientPool":{"concurrentOperationLimit":100,"maxIdleClients":1,"activeClients":{},"failedClients":{},"terminated":false,"terminateDeferred":{"promise":{}}}},"_path":{"segments":["messages","uo3QAC73RkNuoK445lDx"],"projectId":"sample","databaseId":"(default)"},"_converter":{}},"_serializer":{"allowUndefined":false},"_readTime":{"_seconds":1611687729,"_nanoseconds":274000000},"_createTime":{"_seconds":1611687729,"_nanoseconds":274000000},"_updateTime":{"_seconds":1611687729,"_nanoseconds":274000000}}

at Function.run (src/index.ts:10:13)

console.log
{"eventId":"8ypi6ez73efk39maxif8p","resource":{"service":"firestore.googleapis.com","name":"projects/sample/databases/(default)/documents/messages/uo3QAC73RkNuoK445lDx"},"eventType":"providers/cloud.firestore/eventTypes/document.create","timestamp":"2021-01-26T19:02:09.275Z","params":{"uid":"uo3QAC73RkNuoK445lDx"}}

at Function.run (src/index.ts:11:13)

(node:2767) V8: /home/ubuntu/workspace/blinktrade/otc/firebase/functions/node_modules/openpgp/dist/openpgp.js:2491 Linking failure in asm.js: Unexpected stdlib member
(node:2767) V8: /home/ubuntu/workspace/blinktrade/otc/firebase/functions/node_modules/openpgp/dist/openpgp.js:1083 Linking failure in asm.js: Unexpected stdlib member
PASS tests/crypto.test.ts
PASS tests/helpers.test.ts

Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 2.994 s, estimated 3 s
Ran all test suites.
✔ Script exited successfully (code 0)
i emulators: Shutting down emulators.
i firestore: Stopping Firestore Emulator
i hub: Stopping emulator hub
正常吗?

最佳答案

您可以通过按顺序而不是并行运行所有测试来解决此问题。
所以而不是这个:

jest --watch
尝试这个:
jest --watch --runInBand

关于与 Jest 一起使用时 Firebase 模拟器泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65907608/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com