### Checkly Project Setup Prompts Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/startup-guide-detect-communicate-resolve.md Example dialog shown during the Checkly project creation process, guiding through setup options. ```bash Hi Nica Mellifera! Let's get you started on your monitoring as code journey! ✔ Where do you want to create your new project? … detect-comm-resolve ◼ Cool. Your project will be created in the directory "/Users/nica/checkly/examples/detect-comm-resolve" ? Which template would you like to use for your new project? › - Use arrow-keys. Return to submit. ❯ An advanced TypeScript project with multiple examples and best practices (recommended) An advanced JavaScript project with multiple examples and best practices A boilerplate TypeScript project with basic config A boilerplate JavaScript project with basic config ✔ Would you like to install NPM dependencies? (recommended) … yes ✔ Packages installed successfully ✔ Would you like to initialize a new git repo? (optional) … no ``` -------------------------------- ### Install Dependencies and Start Local Server Source: https://github.com/checkly/docs.checklyhq.com/blob/main/README.md Run these commands in your terminal to install project dependencies and start the local development server. ```bash $ npm install $ npm start ``` -------------------------------- ### Install Checkly CLI Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/_index.md Use this command to install the Checkly CLI and start a new project. It will guide you through the setup process. ```bash npm create checkly@latest ``` -------------------------------- ### Start Django App with uWSGI Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/django.md Example startup command for a Django application using uWSGI with specified processes and threads. ```bash uwsgi --http :8000 --wsgi-file myapp.wsgi --master --processes 4 --threads 2 ``` -------------------------------- ### Use Fixtures to Hide Setup Instructions Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/how-to-parameterize-playwright-projects.md This example shows how fixtures can abstract away setup logic, allowing test cases to focus on feature testing. The 'yourPageObjectModel' fixture is requested, simplifying the test function. ```javascript test("feature works", async ({ yourPageObjectModel }) => { /* … */ }) ``` -------------------------------- ### Pulumi CLI Setup Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/pulumi-provider/_index.md Install the Pulumi CLI and log in using a personal access token. The `pulumi whoami` command verifies a successful login. ```bash $ pulumi Pulumi - Modern Infrastructure as Code To begin working with Pulumi, run the `pulumi new` command: $ pulumi new This will prompt you to create a new project for your cloud and language of choice. ... ... ``` ```bash $ pulumi login Manage your Pulumi stacks by logging in. Run `pulumi login --help` for alternative login options. Enter your access token from https://app.pulumi.com/account/tokens or hit to log in using your browser: ``` ```bash $ pulumi whoami YOUR_USER_NAME ``` -------------------------------- ### Start Django App with Gunicorn Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/django.md Example startup command for a Django application using Gunicorn with specified workers and threads. ```bash gunicorn myapp.wsgi -c gunicorn.config.py --workers 2 --threads 2 ``` -------------------------------- ### Initialize New Pulumi Project (JavaScript) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/integrations/pulumi.md Initializes a new Pulumi project using the minimal JavaScript template. This command guides the user through project naming and stack setup. ```bash pulumi new javascript This command will walk you through creating a new Pulumi project. Enter a value or leave blank to accept the (default), and press . Press ^C at any time to quit. project name: (new-pulumi-checkly-project) project description: (A minimal JavaScript Pulumi program) Created project 'new-pulumi-checkly-project' Please enter your desired stack name. To create a stack in an organization, use the format / (e.g. `acmecorp/dev`). stack name: (dev) Created stack 'dev' Installing dependencies... added 96 packages, and audited 97 packages in 4s Finished installing dependencies Your new project is ready to go! ✨ To perform an initial deployment, run 'pulumi up' ``` -------------------------------- ### Install OpenTelemetry SDK and Exporter Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/laravel.md Install the necessary OpenTelemetry SDK components and the OTLP exporter using Composer. This provides the core tracing functionality. ```bash composer require \ open-telemetry/opentelemetry \ open-telemetry/sdk \ open-telemetry/api \ open-telemetry/opentelemetry-auto-slim \ open-telemetry/opentelemetry-auto-laravel \ open-telemetry/exporter-otlp ``` -------------------------------- ### Run Setup and Teardown Scripts in Tests Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/developer-fixtures.md Use `beforeEach` and `afterEach` hooks to run setup and teardown functions before and after each test. This requires repeating the setup in each test file. ```typescript import {setup, teardown } from "./standardScripts.ts" test.beforeEach(() => { setup(); }); //add tests here test.afterEach(() => { teardown(); }); ``` -------------------------------- ### Initialize Page Object Model with Configuration (Before) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/how-to-parameterize-playwright-projects.md This 'before' example demonstrates initializing a page object model directly within a test case, including passing configuration options like email and password. This approach requires repetitive setup in each test. ```typescript // BEFORE import { DashboardPage } from './poms/dashboard-page.ts' test('create check', async ({ page }) => { const dashboardPage = new DashboardPage(page, { email: 'stefan@checklyhq.com', password: '...' }); await dashboardPage.login() await dashboardPage.createCheck() }) ``` -------------------------------- ### Install OpenTelemetry Packages Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/django.md Install the necessary OpenTelemetry packages for SDK, OTLP exporter, and Django instrumentation. ```bash pip install opentelemetry-sdk \ opentelemetry-exporter-otlp \ opentelemetry-instrumentation-django \ requests ``` -------------------------------- ### Setup and Teardown Scripts for Test Data Management Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/multistep-checks/example-checks.md This example uses `beforeAll` and `afterAll` hooks to prepare and clean up test data for a todo list API. It ensures no pre-existing data interferes with the test and removes any created data afterward. Requires a CRUD_API_KEY environment variable. ```typescript import { test, expect } from "@playwright/test" const baseUrl = "https://crudapi.co.uk/api/v1/todo" const headers = { Authorization: `Bearer ${process.env.CRUD_API_KEY}`, "Content-Type": "application/json", } /** * Share state between hooks and test.steps */ let createdResources = null /** * Use `beforeAll` as a setup script * to make sure no todo's exist. */ test.beforeAll(async ({ request }) => { const response = await request.get(baseUrl, { headers }) const { items } = await response.json() expect(items.length).toEqual(0) }) /** * Use `afterAll` as a teardown script * to remove the created todo before the check ends */ test.afterAll(async ({ request }) => { if (createdResources) { const response = await request.delete(baseUrl, { headers, data: createdResources, }) expect(response).toBeOK() } }) test("Todo List", async ({ request }) => { await test.step("Create a Todo", async () => { const response = await request.post(baseUrl, { headers, data: [ { title: "Testing Checkly Multistep checks", done: true, }, ], }) expect(response).toBeOK() const { items } = await response.json() createdResources = items }) }) ``` -------------------------------- ### Install OpenTelemetry Packages Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/flask.md Install the necessary OpenTelemetry packages for OTLP export and Flask instrumentation. ```bash pip install opentelemetry-distro \ opentelemetry-exporter-otlp ``` -------------------------------- ### Setup Script to Set Authorization Header Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/api-checks/setup-teardown-scripts.md A setup script can fetch a token asynchronously using top-level await and set it as the 'Authorization' header for the request. ```typescript import { getToken } from './common/auth-client' const token = await getToken() request.headers['Authorization'] = `Bearer ${token}` ``` -------------------------------- ### Install OpenTelemetry SDK for Go Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/go.md Installs the necessary OpenTelemetry packages for Go applications. Ensure you have Go installed and configured. ```bash go get "go.opentelemetry.io/otel" \ "go.opentelemetry.io/otel/propagation" \ "go.opentelemetry.io/otel/sdk/trace" \ "go.opentelemetry.io/otel/exporters/otlp/otlptrace" \ "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" \ "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ``` -------------------------------- ### Install OpenTelemetry Packages Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/express.md Install the necessary OpenTelemetry packages for Node.js instrumentation. ```bash npm install --save \ @opentelemetry/sdk-node \ @opentelemetry/exporter-trace-otlp-proto \ @opentelemetry/auto-instrumentations-node \ @opentelemetry/sdk-trace-base \ @opentelemetry/api ``` -------------------------------- ### uWSGI Installation for OpenTelemetry Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/django.md Install the `uwsgidecorators` package required for uWSGI integration with OpenTelemetry. ```bash pip install uwsgidecorators ``` -------------------------------- ### Start Laravel Application Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/traces-open-telemetry/instrumenting-code/laravel.md Start your Laravel application using the artisan serve command after configuring OpenTelemetry. ```bash php artisan serve ``` -------------------------------- ### SSL Alert Example Output Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/alerting-and-retries/webhooks.md Example of a customized SSL alert message, showing how dynamic variables can be incorporated. ```json { "message": "The SSL certificate for api.checklyhq.com will expire in 14 days", "link": "http://app-test.checklyhq.com/checks/08437f9c-df8c-45ed-975a-a3f9e24d626d" } ``` -------------------------------- ### Define API Check with Setup Script Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/api-checks/setup-teardown-scripts.md Configure an API check to use a specific setup script by providing the entrypoint in the `setupScript` configuration. ```typescript import { ApiCheck } from '@checkly/cli/constructs' import * as path from 'path' new ApiCheck('api-check-1', { name: 'Fetch Product Data', setupScript: { entrypoint: path.join(__dirname, 'setup.ts'), }, request: { method: 'GET', url: 'https://api.acme.com/v1/products' } }) ``` -------------------------------- ### Build and Deploy Documentation Source: https://github.com/checkly/docs.checklyhq.com/blob/main/README.md Use these commands to build the documentation for deployment and to initiate the deployment process. ```bash $ npm run build $ npm run deploy ``` -------------------------------- ### Basic Browser Check Example Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/browser-checks/_index.md This is a basic example of a Browser check using Playwright. It navigates to a URL and asserts that the response status is less than 400. Ensure you have Playwright installed. ```TypeScript import { expect, test } from '@playwright/test' test('Visit Checkly HQ page', async ({ page }) => { const response = await page.goto('https://checklyhq.com') // Test that the response did not fail expect(response.status()).toBeLessThan(400) }) ``` ```JavaScript const { expect, test } = require('@playwright/test') test('Visit Checkly HQ page', async ({ page }) => { const response = await page.goto('https://checklyhq.com') // Test that the response did not fail expect(response.status()).toBeLessThan(400) }) ``` -------------------------------- ### ECMAScript Setup Script with Top-Level Await Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/using-constructs.md Illustrates a setup script in ECMAScript that uses top-level await to asynchronously retrieve an authentication token before setting request headers. ```javascript // __checks__/utils/setup.mjs import { getToken } from './auth-client.mjs' // top-level-await available request.headers['X-My-Auth-Header'] = await getToken() ``` -------------------------------- ### Example Project Directory Tree Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/project-structure.md Illustrates the typical organization of files and directories within a Checkly CLI project. ```bash . |-- checkly.config.ts |-- package.json `-- src `-- __checks__ |-- alert-channels.ts |-- api-check.check.ts `-- homepage.spec.ts ``` -------------------------------- ### Ping Heartbeat with Python Requests Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/heartbeat-monitors/ping-examples.md This Python example uses the 'requests' library to send a GET request to a Checkly Heartbeat URL. It includes a timeout of 5 seconds for the request. ```python import requests # Heartbeat URL url = "https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc" # A GET request to the Heartbeat response = requests.get(url, timeout=5) ``` -------------------------------- ### Project Setup with Checkly CLI Source: https://context7.com/checkly/docs.checklyhq.com/llms.txt Commands to bootstrap, authenticate, test, and deploy monitoring projects using the Checkly CLI. ```APIDOC ## Project Setup with the Checkly CLI The `npm create checkly@latest` command scaffolds a new monitoring project with example checks and a `checkly.config.ts` configuration file that sets global defaults for all checks. ```bash # Bootstrap a new Checkly monitoring project npm create checkly@latest # Authenticate npx checkly login # Dry-run all checks against the Checkly cloud npx checkly test # Expected output: # Running 4 checks in eu-west-1. # src/__checks__/api.check.ts # ✔ Books API (222ms) # src/__checks__/home.check.ts # ✔ Home page (24s) # 4 passed, 4 total # Deploy checks so they run on a schedule npx checkly deploy ``` ``` -------------------------------- ### Playwright Tests with Hooks and Grouping Source: https://context7.com/checkly/docs.checklyhq.com/llms.txt Example of Playwright tests using `test.describe` for grouping and `test.beforeEach`/`test.afterEach` hooks for setup and cleanup. Ensure USER_EMAIL and USER_PASSWORD environment variables are set. ```typescript // example.spec.ts — grouped tests with before/after hooks import { expect, test } from '@playwright/test' test.describe('Shopping cart flow', () => { test.beforeEach(async ({ page }) => { await page.goto('https://shop.acme.com') await page.getByLabel('Email').fill(process.env.USER_EMAIL!) await page.getByLabel('Password').fill(process.env.USER_PASSWORD!) await page.getByRole('button', { name: 'Sign in' }).click() await expect(page.getByTestId('user-menu')).toBeVisible() }) test('add item to cart', async ({ page }) => { await page.getByTestId('product-card').first().getByRole('button', { name: 'Add to cart' }).click() await expect(page.getByTestId('cart-count')).toHaveText('1') }) test('proceed to checkout', async ({ page }) => { await page.goto('https://shop.acme.com/cart') await page.getByRole('button', { name: 'Checkout' }).click() await expect(page).toHaveURL(///checkout/) }) test.afterEach(async ({ page }) => { // Clean up — remove items from cart after each test await page.goto('https://shop.acme.com/cart/clear') }) }) ``` -------------------------------- ### Initiate Import Process Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/import.md Run this command to generate the code for all resources not yet managed by the CLI. This step allows for a review before any changes are made to your account. ```bash npx checkly import ``` -------------------------------- ### Configure Playwright Check Suite with Tags and Projects Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/playwright-checks/reference.md This example demonstrates how to configure a Playwright Check Suite using both `pwTags` and `pwProjects` to target specific tests. It also includes a comment explaining the monitoring setup. ```typescript export default defineConfig({ // ... checks: { playwrightConfigPath: './playwright.config.ts', playwrightChecks: [ { /** * Run critical tagged tests in Chromium * every minute from 4 locations. */ name: 'critical-tagged', pwTags: '@critical', pwProjects: 'chromium', frequency: Frequency.EVERY_1M, locations: ['us-east-1', 'eu-west-1','eu-central-1', 'ap-south-1'], }, ], }, }); ``` -------------------------------- ### Complete Setup Script for Dynamic Data Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/setup-scripts-for-apis.md Combine fetching data with axios, mapping it to the desired schema, and stringifying it for the request body in a complete setup script. ```javascript const axios = require('axios') // import axios library explicitly const { data } = await axios({ method: "GET", url: "https://random-data-api.com/api/device/random_device", }) const responseData = { // create the response body object title: data.model, price: data.id, description: data.manufacturer, category: "device" } request.body = JSON.stringify(responseData) // set request body to stringified response body object ``` -------------------------------- ### Independent Test Sequence Example Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/writing-tests.md Shows how to refactor tests to be independent by encapsulating setup logic within each test. This approach allows tests to be run in any order, even concurrently, improving flexibility and reducing total runtime. ```text test1: - creates user1 - asserts user1 has been created test2: - (setup: creates user1) - logs in with user1 - asserts user1 has logged in successfully test3: - (setup: creates user1) - (setup: logs in with user1) - goes through checkout as user1 - asserts that checkout for user1 was successful ``` -------------------------------- ### Set Up and Run a Basic Selenium Test Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/playwright-vs-selenium.md Configure a browser instance, navigate to a URL, interact with elements, and close the browser. Ensure the 'chrome' browser driver is installed and accessible. ```javascript async function exampleTest() { // Initialize a new browser instance const driver = await new Builder().forBrowser('chrome').build(); try { // Navigate to a website await driver.get('https://www.example.com'); // Perform actions or assertions const title = await driver.getTitle(); console.log('Page Title:', title); // Find an element and interact with it const element = await driver.findElement(By.name('exampleInput')); await element.sendKeys('Test Input'); // Wait for some condition, if necessary await driver.wait(until.titleIs('Expected Title'), 5000); } finally { // Clean up and close the browser await driver.quit(); } } // Run the test exampleTest(); ``` -------------------------------- ### Use Fixture for Page Object Model Initialization (After) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/how-to-parameterize-playwright-projects.md This 'after' example illustrates how a fixture can handle the initialization of a page object model, making test cases cleaner. The test directly requests 'dashboardPage', abstracting the setup and configuration. ```typescript // AFTER test('create check', async ({ dashboardPage }) => { await dashboardPage.createCheck() }) ``` -------------------------------- ### Pulumi Up Deployment Output Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/pulumi-provider/_index.md Example output from running `pulumi up` to preview and apply changes for Checkly resources. It shows the creation of API and Browser checks. ```bash $ pulumi up Previewing update (dev) View Live: https://app.pulumi.com/stefanjudis/new-pulumi-checkly-project/dev/previews/b30010eb-53a6-438a-864b-af29c2f1321f Type Name Plan pulumi:pulumi:Stack new-pulumi-checkly-project-dev + ├─ checkly:index:Check my-browser-check-pulumi create + └─ checkly:index:Check my-api-check-pulumi create Resources: + 2 to create 1 unchanged Do you want to perform this update? yes Updating (dev) View Live: https://app.pulumi.com/stefanjudis/new-pulumi-checkly-project/dev/updates/2 Type Name Status pulumi:pulumi:Stack new-pulumi-checkly-project-dev + ├─ checkly:index:Check my-api-check-pulumi created + └─ checkly:index:Check my-browser-check-pulumi created Resources: + 2 created Duration: 2s ``` -------------------------------- ### GitHub Actions CI/CD Integration for Checkly Source: https://context7.com/checkly/docs.checklyhq.com/llms.txt Example GitHub Actions workflow to run Checkly tests on deployment status events. It checks out code, sets up Node.js, installs dependencies, runs checks, and optionally deploys them to production. ```yaml # .github/workflows/checkly.yml name: 'checkly' on: [deployment_status] env: CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }} CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }} ENVIRONMENT_URL: ${{ github.event.deployment_status.environment_url }} CHECKLY_TEST_ENVIRONMENT: ${{ github.event.deployment_status.environment }} jobs: test-e2e: if: github.event.deployment_status.state == 'success' name: Test E2E on Checkly runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v3 with: ref: "${{ github.event.deployment_status.deployment.ref }}" fetch-depth: 0 - name: Set branch name run: echo "CHECKLY_TEST_REPO_BRANCH=$(git show -s --pretty=%D HEAD | tr -s ',' '\n' | sed 's/^ //' | grep -e 'origin/' | head -1 | sed 's/\origin\///g')" >> $GITHUB_ENV - uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' - name: Install dependencies run: npm ci - name: Run checks run: npx checkly test -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }} --reporter=github --record - name: Create summary run: cat checkly-github-report.md > $GITHUB_STEP_SUMMARY - name: Deploy checks if: github.event.deployment_status.environment == 'production' run: npx checkly deploy --force ``` -------------------------------- ### Define a URL Monitor Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/constructs-reference.md Use UrlMonitor to track basic availability and HTTP status codes. This example defines monitor properties, sends a GET request, asserts an HTTP 200 OK response, and sets degradation thresholds. ```typescript import { UrlMonitor, UrlAssertionBuilder } from 'checkly/constructs' new UrlMonitor('hello-url-1', { name: 'Hello URL', activated: true, maxResponseTime: 10000, degradedResponseTime: 5000, request: { url: 'https://httpbin.org/get', skipSSL: false, followRedirects: true, assertions: [ UrlAssertionBuilder.statusCode().equals(200), ] } }) ``` -------------------------------- ### Playwright Login Test Spec Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/login-automation.md This TypeScript spec file demonstrates a basic login automation flow using Playwright. It fills in username and password fields and clicks the login button. Ensure you have the necessary Playwright setup and dependencies installed. ```typescript import { test, expect } from "@playwright/test"; test.describe("Login Test", () => { test("should login successfully", async ({ page }) => { // Navigate to the login page await page.goto("https://danube-web.shop/login"); // Fill in the username/email field await page.locator("#email").fill(process.env.USER_EMAIL as string); // Fill in the password field await page.locator("#password").fill(process.env.USER_PASSWORD as string); // Click the login button await page.locator("button[type='submit']").click(); // Wait for navigation to complete and check for an element that indicates successful login await page.waitForNavigation(); await expect(page.locator(".user-menu")).toBeVisible(); }); }); ``` -------------------------------- ### Example .env file content Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/using-environment-variables.md Store your environment variables in a .env file. Remember to add this file to your .gitignore to prevent committing sensitive information. ```dotenv ENVIRONMENT_URL=https://checklyhq.com USER_NAME=admin PASSWORD=admin ``` -------------------------------- ### Define an API Check Resource Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/monitoring-ecommerce-apps-using-playwright.md Configure an API Check to monitor endpoint health, response times, and data integrity. This example sets up a GET request to a book listing API with assertions for status code and JSON body length. ```typescript // __check__/api.check.ts import { ApiCheck, AssertionBuilder } from '@checkly/cli/constructs' const api = new ApiCheck('webstore-list-books', { name: 'List Books API', locations: ['eu-central-1','us-west-1'], // overrides the locations property frequency: 1, // overrides the frequency property doubleCheck: true, degradedResponseTime: 5000, maxResponseTime: 10000, request: { method: 'GET', url: 'https://danube-web.shop/api/books', assertions: [ AssertionBuilder.statusCode().equals(200), AssertionBuilder.jsonBody('$.length').equals('30') ] } }) ``` -------------------------------- ### Checkly Deployment Response Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/startup-guide-detect-communicate-resolve.md This is an example of the output received after successfully deploying a Checkly project. ```bash $npx checkly deploy Parsing your project... ✅ Validating project resources... ✅ Bundling project resources... ✅ ✔ You are about to deploy your project "New Walkthrough Project" to account "nica@checklyhq.com". Do you want to continue? … yes Successfully deployed project "New Walkthrough Project" to account "nica@checklyhq.com". ``` -------------------------------- ### Bootstrap a new Checkly monitoring project Source: https://context7.com/checkly/docs.checklyhq.com/llms.txt Use this command to scaffold a new monitoring project with example checks and a configuration file. Ensure you are authenticated before running other commands. ```bash npm create checkly@latest npx checkly login npx checkly test # Expected output: # Running 4 checks in eu-west-1. # src/__checks__/api.check.ts # ✔ Books API (222ms) # src/__checks__/home.check.ts # ✔ Home page (24s) # 4 passed, 4 total npx checkly deploy ``` -------------------------------- ### Creating a Reusable Login Fixture in Playwright Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/developer-fixtures.md This example demonstrates how to extend Playwright's test fixture to encapsulate common setup logic, such as user authentication. This fixture can then be reused across multiple tests, promoting DRY principles and simplifying maintenance. ```typescript import { test as baseTest, expect } from '@playwright/test'; const test = baseTest.extend({ userPages: async ({ page }, use) => { // Your setup logic here await page.goto('https://danube-webshop.herokuapp.com/'); await page.getByRole('button', { name: 'Log in' }).click(); await page.getByPlaceholder('Email').click(); await page.getByPlaceholder('Email').fill('robert@moresby.com'); await page.getByPlaceholder('Password').click(); await page.getByPlaceholder('Password').fill('@!#KLjwsWe4@'); await page.getByRole('button', { name: 'Sign In' }).click(); console.log('setup'); // After logging in, pass the `page` // object to the test cases // // Whatever you call `use` with // will be available in your test cases await use(page); // Teardown logic, if any console.log('teardown'); }, }); //Now we can use that userPages object repeatedly test('display recent orders', async ({ userPages }) => { // any code added here can make normal expectaions of the page! }); test('cancel recent order', async ({ userPages }) => { // any code added here can make normal expectaions of the page! }); ``` -------------------------------- ### Ping Vercel Cron Job (Next.js Pages Router) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/heartbeat-monitors/ping-examples.md This JavaScript example is for Next.js Pages Router cron jobs. It sends a GET request to your Checkly Heartbeat URL upon completion of your job tasks, with error logging for the fetch operation. ```javascript export default function handler(req, res) { // Your job tasks here ... // Ping URL const URL = 'https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc'; // GET request to the Heartbeat try { const response = await fetch(URL); console.log(`Checkly heartbeat ping status ${response.status}`); } catch (error) { console.log(`Checkly heartbeat ping failed: ${error}`) } } ``` -------------------------------- ### Preview Deploy with Checkly CLI Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/cli/command-line-reference.md Use the `--preview` flag to see the differences between your local configuration and your Checkly account before deploying. This helps in understanding the impact of your deployment. ```bash npx checkly deploy --preview ``` -------------------------------- ### Full Keyword Monitoring Test Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/keyword-monitoring.md This example demonstrates a complete Playwright test for a keyword monitor. It navigates to a URL, asserts the visibility of a specific best-selling book title and its price, and takes a screenshot. This setup is ideal for ensuring critical product information remains accessible. ```tsx const { expect, test } = require('@playwright/test') test('Check for my best seller', async ({ page }) => { const response = await page.goto('https://danube-webshop.herokuapp.com/') await expect(page.getByText('Haben oder haben')).toBeVisible() await expect(page.getByText('9.95').first()).toBeVisible() // Take a screenshot await page.screenshot({ path: 'screenshot.jpg' }) }) ``` -------------------------------- ### Deploy Checkly Configuration Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/playwright-checks/add-to-group.md Use the Checkly CLI to deploy your configuration changes. Run `--preview` to confirm before deploying. ```bash npx checkly deploy --preview #confirm what will be deployed npx checkly deploy # deploy ``` -------------------------------- ### Initialize Terraform Project Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/monitoring-ecommerce-apps-using-terraform.md This command initializes the Terraform working directory, downloading the necessary provider plugins. Ensure you have the Checkly provider configured. ```bash terraform init ``` -------------------------------- ### Recording Deployments with Trigger Parameters Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/CICD/triggers.md This cURL example demonstrates how to use optional query parameters with a trigger URL to record a deployment event. Providing 'deployment=true' along with 'repository' and 'sha' will log the deployment in the Checkly event timeline. Subsequent requests with the same repository and SHA will not create a new deployment event. ```bash curl -X GET "https://api.checkly.com/checks//trigger/c0hYw?deployment=true&repository=acme/customer-api&sha=v1.0.2-beta" ``` -------------------------------- ### Install Playwright Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/monitoring-ecommerce-apps-using-playwright.md Install Playwright as a development dependency in your project. ```bash npm init playwright@latest ``` -------------------------------- ### Global Setup and Teardown with Hooks Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/test-fixtures.md Use `test.beforeEach` and `test.afterEach` to execute code before and after each test case. This approach is suitable for simpler scenarios but can lead to code duplication if used across multiple spec files. ```javascript test.beforeEach(async ({}) => { console.log(`Start time: ${new Date()}`); }); test('my test', async ({ page }) => { expect(page.url()).toBe('https://my.start.url/'); }); test.afterEach(async ({}) => { console.log(`End time: ${new Date()}`); }); ``` -------------------------------- ### Install Checkly CLI Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/monitoring-ecommerce-apps-using-playwright.md Install the Checkly CLI as a development dependency. ```bash npm i --save-dev @checkly/cli ``` -------------------------------- ### Create New Checkly Project Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/guides/monitoring-ecommerce-apps-using-playwright.md Use this command to bootstrap a new project with the Checkly CLI. ```bash npm create checkly ``` -------------------------------- ### Install Playwright Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/learn/playwright/playwright-vs-selenium.md Install Playwright as a development dependency in your project using npm. ```bash npm install --save-dev playwright ``` -------------------------------- ### Download GitHub Copilot Instructions (Windows) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/ai/use-checkly-with-ai-ide.md Download the Checkly rules file for GitHub Copilot on Windows systems. ```powershell New-Item -ItemType Directory -Path ".github\instructions" -Force Invoke-WebRequest -Uri "https://www.checklyhq.com/docs/ai/docs/ai/checkly.rules.md" -OutFile ".github\copilot-instructions.md" ``` -------------------------------- ### Install Checkly CLI Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/playwright-checks/_index.md Install the Checkly CLI as a dev dependency in your project. ```bash npm install --save-dev checkly ``` -------------------------------- ### Setup WebSocket Connection (JavaScript) Source: https://github.com/checkly/docs.checklyhq.com/blob/main/site/content/docs/multistep-checks/websockets.md Use this to establish a WebSocket connection in JavaScript. Replace the placeholder URL with your WebSocket server's address. ```javascript const WebSocket = require('ws'); const url = 'wss://your.websocketserver.com'; const ws = new WebSocket(url); ```