最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cypress - mocking window property - Stack Overflow

programmeradmin1浏览0评论

I have a code that uses window.foo.abc as a condition to display something.

I want to test this functionality with cypress and I want to mock this value to be false and true.

How can I do that?

I've tried

 before(function() {
      Cypress.on('window:before:load', win => {
        win.foo.abc = true;
      });

and

  cy.window().then(win => {
    window.foo.abc = true;
  });

with no success.

How can I mock this value?

thanks

发布评论

评论列表(0)

  1. 暂无评论