gpt4 book ai didi

electron - Cypress : Electron 不支持.finally()吗?

转载 作者:行者123 更新时间:2023-12-03 12:21:15 24 4
gpt4 key购买 nike

Electron 3.x添加了对javascript .finally()的支持

我有一个问题,因为我的Vue应用在处理axios请求时实际上正在使用.finally。

由于.finally(),使用 Electron 进行的柏树测试失败。 ...

I cannot ask the team to refactor code for a problem only with a test suite and only with the 'auto' mode because we're still working on local culture to accept to spend time across testing. If I ask this to the devs, someone will shutdown testing...



问题: 是否有办法使Electron能够消化此语法?

该webapp由Laravel 5.8.x,Vue 2和axios组成,并通过webmix(webpack链)进行编译。

最佳答案

您有两种选择:

  • 可以将cypress升级到3.5.0,即uses Electron5。
  • 或使用polyfill。

    首先,安装es-shims/Promise.prototype.finally:
    npm install -D promise.prototype.finally

    然后,在您的cypress/support/index.js中:

    const { implementation: FinallyPolyfill } = require('promise.prototype.finally');

    function loadPolyfill ( win ) {
    win.Promise.prototype.finally = FinallyPolyfill;
    }

    // polyfill AUT's Promise
    Cypress.on('window:before:load', win => {
    loadPolyfill(win);
    });

    // polyfill Cypress runner's wrapper window Promise
    before(() => {
    loadPolyfill(window);
    });
  • 关于electron - Cypress : Electron 不支持.finally()吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58621179/

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