BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[OTHER] <Test error for "event listed" test on the /events end point>

Open jackli921 opened this issue 3 years ago • 10 comments

What would you like to share?

   Error: expect(received).toBeGreaterThan(expected)

    Matcher error: received value must be a number or bigint

    Received has type:  object
    Received has value: {"_frame": {"_guid": "frame@9ba2e5f7edd95b256e626fef153667cf", "_type": "Frame"}, "_selector": "li"}

      21 | test("Events listed", async ({ page }) => {
      22 |   await page.goto("/events");
    > 23 |   await expect(page.locator("li")).toBeGreaterThan(1);
         |                                    ^
      24 | });
      25 |
      26 | test.describe("accessibility tests (light)", () => {

        at /Users/jack/Documents/Dev/LinkFree/tests/events.spec.js:23:36

  1 failed
    [chromium] › events.spec.js:21:5 › Events listed 

This error occurs because the "toBeGreaterThan" matcher expects a numeric or bigint value as the "received" parameter. However, the value passed to the expect function is an object with information about the located elements.

Additional information

No response

jackli921 avatar Aug 16 '23 14:08 jackli921

To reduce notifications, issues are locked until they are https://github.com/EddieHubCommunity/LinkFree/labels/%F0%9F%8F%81%20status%3A%20ready%20for%20dev and to be assigned. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar Aug 16 '23 14:08 github-actions[bot]

Good spot 👍 I think because no data has been loaded yet, so we should have the automated tests add some event data

eddiejaoude avatar Aug 16 '23 15:08 eddiejaoude

The issue has been unlocked and is now ready for dev. If you would like to work on this issue, you can comment to have it assigned to you. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar Aug 16 '23 15:08 github-actions[bot]

Good spot 👍 I think because no data has been loaded yet, so we should have the automated tests add some event data

The "events" directory within "tests/data/_test-profile-user-6" includes two example json files as shown in the below screenshot. I believe they are supposed to load when the test runs. Please correct me if my assumptions are wrong.

Screenshot 2023-08-16 at 12 12 29

To fix the current issue, I propose that we modify our test expectation to properly check the count of the located elements using the .count() method provided by Playwright's Locator:

test("Events listed", async ({ page }) => {
  await page.goto("/events");
  const elements = await page.locator("li").count();
  await expect(elements).toBeGreaterThan(1);
});

jackli921 avatar Aug 16 '23 16:08 jackli921

Can I work on This?

Pravesh-Sudha avatar Aug 17 '23 12:08 Pravesh-Sudha

Can I work on This?

@Pravesh-Sudha I have assigned this to you

SaraJaoude avatar Aug 18 '23 09:08 SaraJaoude

@jackli921 I got a question , you mentioned in the above comment that we should use test("Events listed", async ({ page }) but the source code include: test.fixme("Events listed", async ({ page }) What should I use ?

Pravesh-Sudha avatar Aug 19 '23 10:08 Pravesh-Sudha

@jackli921 I got a question , you mentioned in the above comment that we should use test("Events listed", async ({ page }) but the source code include: test.fixme("Events listed", async ({ page }) What should I use ?

Hi Pravesh, I removed the .fixme part so that the test can run. .fixme is included, the test will skip that one. If the changes you've made works, then you can submit a pull request without the .fixme I believe. You can always confirm it with one of the maintainers.

jackli921 avatar Aug 21 '23 16:08 jackli921

Thanks @jackli921 for the guidance, I have submitted the PR

Pravesh-Sudha avatar Aug 22 '23 03:08 Pravesh-Sudha

Great collaboration 💪

eddiejaoude avatar Aug 22 '23 07:08 eddiejaoude