I am trying the following synthetics inline script on elastic cloud.
The line expect(productImages.length).toBe(9);
is causing error Error: expect(received).toBe(expected) // Object.is equality
Following is the inline code i am trying
const URL = 'https://elastic-synthetics-demo-ecommerce.vercel.app/';
step('visit landing page', async () => {
await page.goto(params.url || URL, { waitUntil: 'networkidle' });
// check to make sure all products are loaded
const productImages = await page.$$('.card img');
expect(productImages.length).toBe(9);
});
If we look into monitor and look at "Script executed at this step" it looks like following. You can notice on $ instead of $$ in front of ('.card img');
I suspect that is the issue as $('.card img');
is not returning an array.
async () => {
await page.goto(params.url || URL, { waitUntil: 'networkidle' });
// check to make sure all products are loaded
const productImages = await page.$('.card img');
expect(productImages.length).toBe(9);
}