我们的角度项目中有很多柏树试验。但是我们希望使用k6作为我们的新的主要负载测试工具。但我们也想保持我们已经写好的柏树测试。
是否可以在k6中执行柏树测试?例如,使用1000个VUs运行k6,而不是使用k6测试脚本,而是使用柏树测试scrpts。
发布于 2022-06-16 01:30:17
这里有一篇文章:使用Cypress自动记录k6脚本
很多步骤,但是要更新Cypress v10的before:browser:launch钩子语法:
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
}发布于 2022-10-26 05:05:03
上面的回答是一个很好的建议。我使用了上面提到的那篇文章,只是做了一些小小的修改(我在中间的帖子上提到过)。
对于柏树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
}
})
},
},
});如果您使用像cypress.dev-config.js这样的env配置文件,那么上面的e2e部分就会用到
在岗位上的其他指令应该工作得很好。
https://stackoverflow.com/questions/72639421
复制相似问题