Skip to content

Artillery/Playwright does not execute using YML/JS example found on docs #3599

@tgrisley

Description

@tgrisley

2.0.24

Following the docs to implement artillery + playwright

Running this command:

npx artillery run hello-world.yml

I expected to see this happen:

Artillery/Playwright test to be ran as expected according to the docs

Instead, this happened:

⠹ worker error, id: 1 ReferenceError [Error]: module is not defined
    at file:///Users/user/Documents/repos/engagement/load/tests/flow.js:1:1
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:329:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1411:24)
    at Module._compile (node:internal/modules/cjs/loader:1544:5)
    at Object..js (node:internal/modules/cjs/loader:1668:16)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)

If i change flows.js to use export default instead of modules, i get the following:

⠴ WARNING: engine playwright specified but module artillery-engine-playwright could not be loaded
TypeError: Cannot add property $rewriteMetricName, object is not extensible
    at new PlaywrightEngine (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/artillery-engine-playwright/index.js:47:41)
    at loadEngine (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:57:24)
    at /Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:3585:27
    at /Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:3032:24)
    at /Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:4936:18
    at baseMap (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:3584:7)
    at Function.map (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:9622:14)
    at loadEngines (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:46:27)
    at runner (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:162:44)
Phase started: unnamed (index: 0, duration: 1s) 14:01:25(+0100)

⠧ worker error, id: 1 TypeError [Error]: Cannot read properties of undefined (reading '__name')
    at /Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:313:55
    at Array.find (<anonymous>)
    at /Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:313:41
    at arrayMap (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:653:23)
    at Function.map (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/lodash/lodash.js:9622:14)
    at runScenario (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:309:36)
    at EventEmitter.<anonymous> (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/runner.js:212:25)
    at EventEmitter.emit (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/eventemitter3/index.js:181:35)
    at UniformProcess.<anonymous> (/Users/tomgrisley/Documents/repos/engagement/load/node_modules/@artilleryio/int-core/lib/phases.js:220:12)
    at UniformProcess.emit (node:events:524:28)

i have tried to install artillery-engine-playwright as a seperate package but according to the docs this is pre-bundled with Artillery, either-way i encounter the same issue

Files being used:

yml

config:
  target: https://www.artillery.io
  # Load the Playwright engine:
  engines:
    playwright: {}
  # Path to JavaScript file that defines Playwright test functions
  # TypeScript is also supported
  processor: './flows.js'
scenarios:
  - engine: playwright
    testFunction: helloWorld

flows.js

module.exports = { helloWorld };
 
async function helloWorld(page) {
  // The "page" argument is instance of Playwright Page class:
  // https://playwright.dev/docs/api/class-page/
 
  // Go to https://artillery.io/
  await page.goto('https://www.artillery.io/');
  // Click text=Docs
  await page.click('text=Docs');
}

or

export default { helloWorld };
 
async function helloWorld(page) {
  // The "page" argument is instance of Playwright Page class:
  // https://playwright.dev/docs/api/class-page/
 
  // Go to https://artillery.io/
  await page.goto('https://www.artillery.io/');
  // Click text=Docs
  await page.click('text=Docs');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions