Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ApiCheck, AssertionBuilder
✓ import { ApiCheck, AssertionBuilder } from 'checkly/constructs'
✗ const { ApiCheck, AssertionBuilder } = require('checkly/constructs')
These symbols are used to define API monitoring checks programmatically. CommonJS 'require' syntax is not supported for these ESM-first constructs.
test, expect
✓ import { test, expect } from '@playwright/test'
✗ import { test, expect } from 'checkly'
For browser checks, Checkly CLI leverages Playwright. 'test' and 'expect' are imported directly from '@playwright/test', which should be installed as a dev dependency in your project.
(CLI Commands)
✓ npx checkly <command>
✗ import { deploy } from 'checkly'
The Checkly CLI is primarily interacted with via the `npx checkly` command-line interface. Direct programmatic import of CLI commands from the 'checkly' package for execution is not the intended usage for end-users.
This code defines a simple API check and a Playwright-based browser check for a webshop, demonstrating how to write monitoring as code. It includes instructions for local testing and deployment to the Checkly cloud via the CLI.
import { ApiCheck, AssertionBuilder } from 'checkly/constructs';
import { test, expect } from '@playwright/test';
import * as path from 'path';
// --- API Check Example (api.check.ts) ---
// Define an API check for a public endpoint.
new ApiCheck('books-api-check-1', {
name: 'Books API Status',
request: {
url: 'https://danube-web.shop/api/books',
method: 'GET',
assertions: [
AssertionBuilder.statusCode().equals(200),
AssertionBuilder.jsonBody('$[0].id').isNotNull(),
],
},
});
// --- Browser Check Example (homepage.spec.ts) ---
// Define a Playwright-based browser check for a homepage.
test('webshop homepage loads and has title', async ({ page }) => {
const response = await page.goto('https://danube-web.shop');
expect(response?.status()).toBeLessThan(400); // Expect a successful HTTP status code
await expect(page).toHaveTitle(/Danube WebShop/);
// Optionally take a screenshot upon successful load
const screenshotPath = path.join(process.cwd(), 'homepage.jpg');
await page.screenshot({ path: screenshotPath });
console.log(`Screenshot saved to: ${screenshotPath}`);
});
// To run these checks after saving them in your project (e.g., in `__checks__` directory):
// 1. Install Checkly CLI and Playwright: `npm install --save-dev checkly @playwright/test`
// 2. Log in to your Checkly account: `npx checkly login` (Requires a Checkly account)
// 3. Run tests locally: `npx checkly test`
// 4. Deploy checks to the Checkly cloud: `npx checkly deploy`
checkly --version
Errors
Common errors & fixes
Error: TypeScript loader is missing
The Checkly CLI could not find a suitable TypeScript loader to transpile your `.ts` check files, often due to missing 'jiti' or 'typescript' packages, or incorrect `tsconfig.json` configuration.
fixEnsure `jiti` and `typescript` are installed as `devDependencies` (`npm install --save-dev jiti typescript`) and that your `tsconfig.json` is correctly set up. Using `npm create checkly@latest` is recommended for initial setup.
Error: Cannot find module 'jiti'
The `jiti` peer dependency, required by Checkly CLI for runtime transpilation, is missing from your project's `node_modules`.
fixInstall `jiti` explicitly: `npm install jiti` or `npm install --save-dev jiti`.
Node.js version not supported
Your current Node.js version does not meet the minimum requirements (`^18.19.0 || >=20.5.0`) specified by the `checkly` package's engine field.
fixUpgrade your Node.js environment to a supported version using a tool like `nvm` (e.g., `nvm install 20 && nvm use 20`).
Audit
Dependencies
jitirequiredPeer dependency required for runtime code execution/transpilation of TypeScript check files.