小编Zac*_*ack的帖子

ReferenceError:Github Actions Jest 脚本中未定义 TextEncoder

我遇到一个仅在我的 Github Actions 工作流程中发生的错误(当我在本地运行 Jest 脚本时,没有问题)。我只找到了这个答案这个答案,但错误仍然存​​在。关于下一步要检查什么有什么想法吗?

\n

这是错误:

\n
> jest server/test/test --config=server/test/jest.config.js\n\nFAIL server/test/test.js\n  \xe2\x97\x8f Test suite failed to run\n\n    ReferenceError: TextEncoder is not defined\n\n      at Object.<anonymous> (../../node_modules/mongodb-connection-string-url/node_modules/whatwg-url/dist/encoding.js:2:21)\n      at Object.<anonymous> (../../node_modules/mongodb-connection-string-url/node_modules/whatwg-url/dist/url-state-machine.js:5:34)\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的 Jest 配置和脚本:

\n

笑话配置.js

\n
module.exports = {\n    preset: \'@shelf/jest-mongodb\'\n};\n
Run Code Online (Sandbox Code Playgroud)\n

测试.js

\n
const dotenv = require(\'dotenv\');\nconst path = require(\'path\');\nprocess.env = dotenv.config({path: path.resolve(__dirname, \'.env\')}).parsed;\n\nconst request = require(\'supertest\');\nconst {app, server} = require(\'../server\');\nconst { MongoClient } = require(\'mongodb\');\nconst { TextEncoder } = require(\'util\');\n\nglobal.TextEncoder = TextEncoder;\n\ndescribe(\'GET …
Run Code Online (Sandbox Code Playgroud)

mongodb jestjs github-actions

1
推荐指数
1
解决办法
4647
查看次数

标签 统计

github-actions ×1

jestjs ×1

mongodb ×1