【问题标题】:ReferenceError 'process not defined' when executing Cypress test执行赛普拉斯测试时出现 ReferenceError 'process not defined'
【发布时间】:2021-05-28 09:10:44
【问题描述】:

尝试执行任何测试都会导致弹出此错误。

我使用的是赛普拉斯 6.5.0

真的不知道该做什么。

对图片感到抱歉,但最好以这种方式显示。

还有 StackTrace。

at Object../node_modules/is-ci/node_modules/ci-info/index.js (webpack:///node_modules/is-ci/node_modules/ci-info/index.js:5:1)
at __webpack_require__ (webpack:///webpack/bootstrap:19:1)
at Object../node_modules/is-ci/index.js (webpack:///node_modules/is-ci/index.js:3:18)
at __webpack_require__ (webpack:///webpack/bootstrap:19:1)
at Object.eval (webpack:///node_modules/cypress/lib/util.js:21:14)
at Object../node_modules/cypress/lib/util.js (http://localhost:37869/__cypress/tests?p=test/e2e/support/index.js:87250:31)
at __webpack_require__ (webpack:///webpack/bootstrap:19:1)
at Object.eval (webpack:///node_modules/cypress/index.js:9:14)
at Object../node_modules/cypress/index.js (http://localhost:37869/__cypress/tests?p=test/e2e/support/index.js:82972:31)
at __webpack_require__ (webpack:///webpack/bootstrap:19:1)
From previous event:
at runScriptsFromUrls (http://localhost:37869/__cypress/runner/cypress_runner.js:177985:98)
at Object.runScripts (http://localhost:37869/__cypress/runner/cypress_runner.js:177999:11)
at $Cypress.onSpecWindow (http://localhost:37869/__cypress/runner/cypress_runner.js:167733:19)

【问题讨论】:

    标签: testing cypress


    【解决方案1】:

    看起来你在/support/index.js 中有一些东西(因为它在堆栈跟踪中提到)应该在/plugins/index.js 中(因为它对process 的使用无效,这仅在node.js 中可用)。

    Cypress 运行浏览器进程和后台 node.js 进程。

    /support/index.js用于扩充浏览器进程,/plugins/index.js用于扩充node.js进程。

    如果您在添加库、任务或文件预处理器时混淆了它们,则会收到您所显示类型的错误。

    /support/index.js 中有什么内容?

    【讨论】:

      【解决方案2】:

      有时,Visual Studio Code 会自动导入不必要的库。你应该删除它们。对我来说是

      import { cli } from 'cypress';

      【讨论】:

        【解决方案3】:

        当我在测试中导入 cypress 时发生这种情况,解决了问题

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2023-02-14
          • 1970-01-01
          • 2021-10-20
          • 2020-05-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多