小编que*_*nar的帖子

从数组中的元素创建组合

我有一个如下所示的数组引用:

my $strings = [qw(a b c d)];
Run Code Online (Sandbox Code Playgroud)

我想形成所有可能的组合并创建一个数组数组:

my $output = [qw(qw([a],[b],[c],[d],[a,b],[a,c],[a,d],[b,c],[b,d],[c,d],   [a,b,c],[a,b,d],[b,c,d],[a,b,c,d]))]
Run Code Online (Sandbox Code Playgroud)

我尝试了什么:

foreach my $n(1..scalar(@array)) {
    my $iter = combinations($strings, $n);
    while (my $c = $iter->next) {
        print "@$c\n";
    }
}
Run Code Online (Sandbox Code Playgroud)

arrays perl perl-module perl-data-structures

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

cypress 获取模拟窗口打开的所有参数

我在我的 cypress 测试中嘲笑 window.open 为

cy.visit('url', {
        onBeforeLoad: (window) => {
            cy.stub(window, 'open');
        }
      });
Run Code Online (Sandbox Code Playgroud)

在我的应用程序中 window.open 被称为window.open(url,'_self')

我需要检查 cypress 是否打开了正确的 URL

我需要获取使用的 URL 并检查它是否与正则表达式匹配

const match = newRegExp(`.*`,g)
cy.window().its('open').should('be.calledWithMatch', match); 

Run Code Online (Sandbox Code Playgroud)

我收到错误为


CypressError: Timed out retrying: expected open to have been called with arguments matching /.*/g

    The following calls were made:

    open("https://google.com", "_self") at open (https://localhost:3000/__cypress/runner/cypress_runner.js:59432:22)
Run Code Online (Sandbox Code Playgroud)

cypress

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

如何在testcafe中调用外部异步等待功能

我有helper.js它的功能

async function getLink() {
  try {
    const message = await authorize(content);
    const link = message.match(/href=\"(.*?)\"/i);
    return link[1];
  }
  catch(error) {
    console.log('Error loading:',+error);
    throw(error);
  }
}
module.exports.getLink = getLink;
Run Code Online (Sandbox Code Playgroud)

我想在测试执行后在 testcafe 脚本中使用这个函数

在 test.spec.js 中

import { Selector } from 'testcafe';
let link = '';
fixture My fixture
.page `https://devexpress.github.io/testcafe/example/`;

 test('test1', async t => {

// do something with clientWidth
});
test('test2', async t => {
  // use the getLink function here from the helper.js to get the …
Run Code Online (Sandbox Code Playgroud)

javascript automated-tests web-testing e2e-testing testcafe

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

perl 5.16到5.24之间的主要区别是什么

我如何找到perl 5.16和5.24之间的区别

我能够只获得之前版本之间的差异,即5.22我不想只得到之前版本之间的差异

perl doc给出了前一个之间的区别

perl upgrade

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

如何在 testcafe 中存根 window.open

我想在 testcafe 中模拟 window.open 函数。这样如果我的应用程序调用 window.open 而不是点击实际的,我们可以使用模拟

这样的事情会更好

onBeforeLoad: (window) => {
   cy.stub(window, 'open');
}
Run Code Online (Sandbox Code Playgroud)

testing automated-tests mocking e2e-testing testcafe

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