Heartbeat Synthetics/Browser Monitoring Inline Source with expect

Hi All,

I'm trying to a browser monitor that checks to make sure a selector doesn't exist after a button is clicked. I'm using the inline source, but am getting an error about expect not being defined:

Code:

step('Save', async () => {
  /* Save */
  await Promise.all([
    await expect(page).not.toHaveSelector('.ui-widget-overlay'),
    await page.click('a[role="button"]:has-text("Save")')
  ]);
});

I get the following stack trace:

ReferenceError: expect is not defined
    at Step.eval [as callback] (eval at loadInlineScript (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/cli.ts:54:20), <anonymous>:93:5)
    at Runner.runStep (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/core/runner.ts:239:18)
    at Runner.runSteps (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/core/runner.ts:280:27)
    at Runner.runJourney (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/core/runner.ts:380:27)
    at Runner.run (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/core/runner.ts:446:11)
    at Object.run (/usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/index.ts:45:12)
    at /usr/share/heartbeat/.node/node/lib/node_modules/@elastic/synthetics/src/cli.ts:189:19

Anyone know if its possible to use expect within inline source scripts?

On the synthetics-demo repo it looks like expect is only ever used in script files themselves and never in an inline source script: Search · expect · GitHub

This was fixed in this PR in august, but may not be in the version of heartbeat you're using. That shipped in beta-12 which should be what's in the 7.15.0 release. Which version are you on?

Ah, ok, I'm using 7.14.0 so that explains that. Thanks for the information @Andrew_Cholakian1

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.