是否可以使用K6进行角柏树测试?

发布于 2025-02-07 20:09:02 字数 133 浏览 1 评论 0 原文

我们的角度项目中有很多柏树测试。但是我们希望将K6用作我们的新主负载测试工具。但我们也希望继续我们已经书面的柏树测试。

是否可以在K6中执行柏树测试?例如,使用1000个VU的K6运行K6,但使用柏树测试scrpts,而不是K6测试脚本。

We have a lot of cypress tests in our Angular Project. But we want to use k6 as our new main load testing tool. But also we want to keep our already written cypress tests.

Is it possible to execute cypress tests within k6? e.g run k6 with 1000 VUs but instead of k6 test script, use cypress test scrpts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好久不见√ 2025-02-14 20:09:02

这里有一篇文章:

很多步骤,但是要更新柏树v10的语法之前:浏览器:启动钩子:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser, launchOptions) => {
        if (browser.isHeaded) {
          try {
            launchOptions.extensions.push(...);
          } catch (error) {
            console.log("extension not available"); //when in headless mode
          }
          return launchOptions;
        }
      })
  },
  // other config
}

There's an article here: Using Cypress to automate k6 scripts recording

Lots of steps, but to update for Cypress v10 the syntax for the before:browser:launch hook:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser, launchOptions) => {
        if (browser.isHeaded) {
          try {
            launchOptions.extensions.push(...);
          } catch (error) {
            console.log("extension not available"); //when in headless mode
          }
          return launchOptions;
        }
      })
  },
  // other config
}
云胡 2025-02-14 20:09:02

上面的答案是一个可靠的建议。我使用了该文章指示的,只有轻微的修改(我在媒体帖子上提到了)。

对于Cypress 10+,在Cypress.config.js下

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser = {}, launchOptions) => {
        console.log(launchOptions.args) // print all current args
        //Mac and Linux path
        //const k6path = "k6Files/k6-Browser-Recorder"
        //Windows path
        const k6path = "C:\\Users\\..."
        if (browser.isHeaded) {
          try {
            launchOptions.extensions.push(k6path);
          } catch (error) {
            console.log("extension not available"); //when in headless mode
          }
          return launchOptions
        }
      })
    },
  },
});

,如果您使用的Env Config Files(例如cypress.dev-config.js),则上述

帖子中的E2E部分中的其余指令都可以正常工作。

Answer above was a solid suggestion. I used that article indicated there, only slight modifications (i mentioned it on the medium post).

for cypress 10+, under cypress.config.js

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser = {}, launchOptions) => {
        console.log(launchOptions.args) // print all current args
        //Mac and Linux path
        //const k6path = "k6Files/k6-Browser-Recorder"
        //Windows path
        const k6path = "C:\\Users\\..."
        if (browser.isHeaded) {
          try {
            launchOptions.extensions.push(k6path);
          } catch (error) {
            console.log("extension not available"); //when in headless mode
          }
          return launchOptions
        }
      })
    },
  },
});

if your using env config files like cypress.dev-config.js then above goes in that e2e section

Rest of instruction on the post should work just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文