如何修复:运行炮兵脚本时出现类型错误:fn 不是函数

问题描述 投票:0回答:1

我在运行我的火炮测试文件时收到错误

⠇ 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;

我看过以下推荐,但尚未尝试过:

  • 从不同的位置运行火炮
  • 重新安装火炮

开始调试此问题的最佳方法是什么?据我所见,与该函数相关的所有内容都已正确定义。

javascript async-await playwright artillery
1个回答
0
投票

您需要将函数导出为命名导出。所以:

module.exports = { 
  viewHome 
};

© www.soinside.com 2019 - 2024. All rights reserved.