我在运行我的火炮测试文件时收到错误
⠇ TypeError: fn is not a function
。
这是
yml
布局:
target: "https://www.therisecollection.co/" # Update with your test URL
# Load the Playwright engine:
engines:
playwright: {}
processor: './javascriptTest.js'
phases:
- duration: 60
arrivalRate: 5
name: Warm up
- duration: 120
arrivalRate: 5
rampTo: 50
name: Ramp up load
- duration: 600
arrivalRate: 50
name: Sustained load
scenarios:
- engine: "playwright"
flowFunction: 'viewHome'
flow: []
这是我尝试使用的 JavaScript:
async function viewHome(page) {
await page.goto('https://www.therisecollection.co/');
await page.getByRole('button', { name: 'Home' }).click();
await page.getByRole('button', { name: 'About' }).click();
await page.getByRole('button', { name: 'Home' }).click();
await page.getByRole('button', { name: 'About' }).click();
await page.getByRole('button', { name: 'Home' }).click();
await page.getByRole('button', { name: 'About' }).click();
await page.getByRole('button', { name: 'Home' }).click();
await page.getByRole('button', { name: 'About' }).click();
}
module.export = viewHome;
我看过以下推荐,但尚未尝试过:
开始调试此问题的最佳方法是什么?据我所见,与该函数相关的所有内容都已正确定义。
您需要将函数导出为命名导出。所以:
module.exports = {
viewHome
};