# Heartbeat Synthetics/Browser Monitoring Inline Source with expect

**URL:** <https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [September 29, 2021, 8:24pm UTC](https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518 "2021-09-29T20:24:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [September 29, 2021, 8:24pm UTC](https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518/1 "2021-09-29T20:24:26Z")

</div>

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](https://www.elastic.co/guide/en/beats/heartbeat/current/monitor-browser-options.html#monitor-source-inline), but am getting an error about expect not being defined:

Code:

```auto
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:

```auto
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](https://github.com/elastic/synthetics-demo) it looks like `expect` is only ever used in script files themselves and never in an inline source script: [Search · expect · GitHub](https://github.com/elastic/synthetics-demo/search?q=expect)

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)\
**Post date:** [September 29, 2021, 9:25pm UTC](https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518/2 "2021-09-29T21:25:33Z")

</div>

This was fixed in [this PR](https://github.com/elastic/synthetics/pull/365) in august, but may not be in the version of heartbeat you're using. That shipped in [beta-12](https://github.com/elastic/synthetics/blob/master/CHANGELOG.md#v100-beta12-2021-08-19) which should be what's in the 7.15.0 release. Which version are you on?

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [September 29, 2021, 10:59pm UTC](https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518/3 "2021-09-29T22:59:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 28, 2021, 1:00am UTC](https://discuss.elastic.co/t/heartbeat-synthetics-browser-monitoring-inline-source-with-expect/285518/4 "2021-10-28T01:00:29Z")

</div>

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