我遇到一个仅在我的 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)\nRun Code Online (Sandbox Code Playgroud)\n这是我的 Jest 配置和脚本:
\n笑话配置.js
\nmodule.exports = {\n preset: \'@shelf/jest-mongodb\'\n};\nRun Code Online (Sandbox Code Playgroud)\n测试.js
\nconst 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)