结合使用HTTPS和remoteConnection选项

时间:2019-03-18 14:42:21

标签: automated-tests e2e-testing testcafe

使用remoteConnection选项时是否可以传递--allow-insecure-localhost标志?

我的应用需要使用HTTPS,并且在使用openssl-self-signed-certificate时无法正常运行。

const createTestCafe = require('testcafe');
let runner           = null;
let testcafe         = null;
const selfSignedSertificate = require('openssl-self-signed-certificate');

const sslOptions = {
    key:  selfSignedSertificate.key,
    cert: selfSignedSertificate.cert
};

createTestCafe('localhost', 1337, 1338, sslOptions)
   .then(tc => {
       testcafe = tc;
       runner = tc.createRunner();

       return tc.createBrowserConnection();
    })
    .then(remoteConnection => {
    /* ... */
   // Outputs remoteConnection.url so that it can be visited from the .       remote browser.
     console.log(remoteConnection.url);

    remoteConnection.once('ready', () => {
        runner
        .src('e2e/tests/group/')
        .browsers(remoteConnection)
        .run()
        .then(failedCount => {
             console.log(failedCount);
             testcafe.close();
         });
      });
  });

1 个答案:

答案 0 :(得分:1)

由于连接是远程的,因此TestCafe不负责启动浏览器。因此,您需要传递--allow-insecure-localhost参数-只需使用标志启动浏览器并连接到远程URL。