-
Notifications
You must be signed in to change notification settings - Fork 18
refactor: example projects [tra-1519] #1163
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
Merged
miliberlin
merged 15 commits into
main
from
michelle/tra-1519-check-if-landingpagespects-is-mistakenly-empty
Oct 23, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9670997
feat: adjust example tests [tra-1519]
miliberlin 466adb5
feat: rename files [tra-1519]
miliberlin 60601ff
feat: tweak comments [tra-1519]
miliberlin e15e275
feat: fix config + tests [tra-1519]
miliberlin 1ba38e6
feat: fix jiti version [ta-1519]
miliberlin 9ae66c0
feat: use welcome.checkly for tests [tra-1519]
miliberlin 4a1d4fd
Merge branch 'main' into michelle/tra-1519-check-if-landingpagespects…
miliberlin 058689c
feat: merge
miliberlin 9580901
feat: cleanup [tra-1519]
miliberlin 729e1f2
feat: update readme [tra-1519]
miliberlin 5979762
feat: fix docs url [tra-1519]
miliberlin 83a55b9
feat: fix typo, change dependencies [tra-1519]
miliberlin 3ef598f
feat: revert pw version change [tra-1519]
miliberlin f66485a
feat: export function correctly in common js [tra-1519]
miliberlin 0fa4931
feat: change url again [tra-1519]
miliberlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,52 @@ | ||
| # Checkly Monitoring-as-code: Advanced Project | ||
|
|
||
| This example project shows how you can use the Checkly CLI in a monitoring as code (MaC) workflow. We are using the | ||
| https://checklyhq.com website as a monitoring target. | ||
| This example project shows how you can use the Checkly CLI in a monitoring as code (MaC) workflow. | ||
|
|
||
| 1. Write API Checks and Playwright-powered Browser Checks. | ||
| 1. Write API Checks and Playwright-powered Browser Checks or fully native Playwright Check Suites. | ||
| 2. Add Alert Channels, and dry-run your Checks on 20+ global locations. | ||
| 3. Test -> Deploy: now you have your app monitored around the clock. All from your code base. | ||
|
|
||
| ``` | ||
| npm create checkly@latest -- --template advanced-project | ||
| npm create checkly@latest -- --template advanced-project-js | ||
| ``` | ||
|
|
||
| ## Project Structure | ||
|
|
||
| This project has examples of all Checkly check types and showcases some advanced features. It also adds a GitHub Actions workflow. | ||
|
|
||
| - Running `npx checkly pw-test` will use the `playwright.config.ts` file and run the test suite in Checkly. | ||
| ``` | ||
| . | ||
| ├── README.md | ||
| ├── .github | ||
| │ └── workflow.yml | ||
| ├── src | ||
| │ ├── __checks__ | ||
| │ │ ├── synthetics | ||
| │ │ │ ├── 01-api.check.js | ||
| │ │ │ ├── 02-business-critical.check.js | ||
| │ │ │ ├── 03-browse-and-search.spec.js | ||
| │ │ │ ├── 04-add-to-cart.spec.js | ||
| │ │ │ ├── 05-multi-step-api.spec.js | ||
| │ │ │ └── 06-multi-step-api.check.js | ||
| │ │ ├── uptime | ||
| │ │ │ ├── heartbeat.check.js | ||
| │ │ │ ├── tcp.check.js | ||
| │ │ │ └── url.check.js | ||
| │ │ └── utils | ||
| │ │ ├── alert-channels.js | ||
| │ │ ├── auth-client.js | ||
| │ │ ├── setup.js | ||
| │ │ └── website-groups.check.js | ||
| │ └── tests | ||
| │ ├── login.setup.js | ||
| │ └── webshop-interactions.spec.js | ||
| ├── checkly.config.js | ||
| ├── playwright.config.js | ||
| ├── package.json | ||
| └── package-lock.json | ||
| ``` | ||
|
|
||
| - Running `npx checkly pw-test` will use the `playwright.config.js` file and run the test suite in Checkly. | ||
|
|
||
| - Running `npx checkly test` will look for `.check.js` files and `.spec.js` in `__checks__` directories and execute them in a dry run. | ||
|
|
||
|
|
@@ -53,5 +84,5 @@ npm install --save-dev @playwright/[email protected] | |
|
|
||
| ## Questions? | ||
|
|
||
| Check [our CLI docs](https://www.checklyhq.com/docs/cli/), the [main Checkly docs](https://checklyhq.com/docs) or | ||
| Check [the Checkly CLI docs](https://www.checklyhq.com/docs/cli/), the [main Checkly docs](https://checklyhq.com/docs) or | ||
| join our [Slack community](https://checklyhq.com/slack). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
examples/advanced-project-js/src/__checks__/heartbeat.check.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
examples/advanced-project-js/src/__checks__/multi-step-spacex.check.js
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
examples/advanced-project-js/src/__checks__/synthetics/01-api.check.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| const path = require('path') | ||
| const { ApiCheck, AssertionBuilder } = require('checkly/constructs') | ||
| const { syntheticGroup } = require('../utils/website-groups.check') | ||
|
|
||
| // API checks send an HTTP request to a URL endpoint and validate the response. Read more at: | ||
| // https://www.checklyhq.com/docs/api-checks/ | ||
|
|
||
| new ApiCheck('books-api-check-1', { | ||
| name: 'Books API', | ||
| degradedResponseTime: 10000, // milliseconds | ||
| maxResponseTime: 20000, | ||
| setupScript: { | ||
| // API checks can run arbitrary JS/TS code before or after a check. | ||
| entrypoint: path.join(__dirname, '../utils/setup.js') | ||
| }, | ||
| group: syntheticGroup, | ||
| request: { | ||
| url: 'https://danube-web.shop/api/books', | ||
| method: 'GET', | ||
| followRedirects: true, | ||
| skipSSL: false, | ||
| assertions: [ | ||
| AssertionBuilder.statusCode().equals(200), | ||
| AssertionBuilder.headers('content-type').equals('application/json; charset=utf-8'), | ||
| AssertionBuilder.jsonBody('$[0].id').isNotNull(), | ||
| AssertionBuilder.jsonBody('$[0].author').equals('Fric Eromm'), | ||
| ], | ||
| }, | ||
| runParallel: true, | ||
| }) |
25 changes: 25 additions & 0 deletions
25
examples/advanced-project-js/src/__checks__/synthetics/02-business-critical.check.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| const path = require('path') | ||
| const { BrowserCheck } = require('checkly/constructs') | ||
| const { syntheticGroup } = require('../utils/website-groups.check') | ||
|
|
||
| // Configures two checks for our homepage in a single configuration file. | ||
| // Most settings for these checks are defined in the check group, | ||
| // in /utils/website-groups.check.ts | ||
|
|
||
| new BrowserCheck('browse-and-search-check', { | ||
| name: 'Browse and search', | ||
| group: syntheticGroup, | ||
| code: { | ||
| entrypoint: path.join(__dirname, '03-browse-and-search.spec.js') | ||
| }, | ||
| runParallel: true, | ||
| }) | ||
|
|
||
| new BrowserCheck('login-browser-check', { | ||
| name: 'Add to cart flow', | ||
| group: syntheticGroup, | ||
| code: { | ||
| entrypoint: path.join(__dirname, '04-add-to-cart.spec.js') | ||
| }, | ||
| runParallel: true, | ||
| }) |
22 changes: 22 additions & 0 deletions
22
examples/advanced-project-js/src/__checks__/synthetics/03-browse-and-search.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| const { test, expect } = require('@playwright/test') | ||
|
|
||
| // Source code for a browser check using Playwright Test. Find more Playwright information at | ||
| // https://www.checklyhq.com/learn/playwright/ | ||
|
|
||
| // This environment variable is set in the group configuration in /utils/website-groups.check.ts | ||
| const searchString = process.env.AUTHOR_NAME || "Herman Moulson" | ||
|
|
||
| test('Browse and search for a book', async ({ page }) => { | ||
| // The baseURL can be set in the playwrightConfig of your Checkly config | ||
| await page.goto('/') | ||
| await expect(page.getByRole('heading', { name: 'SPECIAL OFFER: 20% OFF BOOKS' })).toBeVisible() | ||
|
|
||
| // Navigate to Fantasy category and verify a book is visible | ||
| await page.locator('a', { hasText: 'Fantasy' }).click() | ||
| await expect(page.getByText('The Pickled Lynx')).toBeVisible() | ||
|
|
||
| // Use the search bar to search for an author and verify a book is visible | ||
| await page.getByRole('textbox').fill(searchString) | ||
| await page.getByRole('button', { name: 'Search' }).click() | ||
| await expect(page.getByText('Haben oder haben')).toBeVisible() | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Checkly CLI automatically creates this when initiating a git repo. Let's keep it at that instead of having various versions in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!