Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Building an Uptime Monitor has invalid code example (compile time error) #1696

Closed
fatah4561 opened this issue Jan 10, 2025 · 1 comment · Fixed by #1697
Closed

docs: Building an Uptime Monitor has invalid code example (compile time error) #1696

fatah4561 opened this issue Jan 10, 2025 · 1 comment · Fixed by #1697

Comments

@fatah4561
Copy link

fatah4561 commented Jan 10, 2025

I am new to encore and currently exploring by doing the tutorials, in the Building an Uptime Monitor add a test code the $expected inside the string should verify that $site is ${expected ? "up" : "down"} has reference error, I can skip it ofc but just wanna inform that the docs has invalid code and I want to see the working version since it seems a good way to loop the tests. Here is the code

import { describe, expect, test } from "vitest";
import { ping } from "./ping";

describe("ping", () => {
  test.each([
    // Test both with and without "https://"
    { site: "google.com", expected: true },
    { site: "https://encore.dev", expected: true },

    // 4xx and 5xx should considered down.
    { site: "https://not-a-real-site.xyz", expected: false },
    // Invalid URLs should be considered down.
    { site: "invalid://scheme", expected: false },
  ])(
    `should verify that $site is ${expected ? "up" : "down"}`,
    async ({ site, expected }) => {
      const resp = await ping({ url: site });
      expect(resp.up).toBe(expected);
    },
  );
});

here is the link to the tutorials docs
encore dev

here is the error
Screenshot 2025-01-10 at 17 27 49

some other details:
I follow exactly like the tutorials since 1st step including the command for the starter create project, so I expected things to works fine. Thank you.

@fredr
Copy link
Member

fredr commented Jan 10, 2025

Thanks! Will fix the tutorial, the correct code should be:

    `should verify that $site is ${"$expected" ? "up" : "down"}`,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants