Skip to content

Commit

Permalink
Tnolet/update examples and readmes (#904)
Browse files Browse the repository at this point in the history
* feat: clean up examples, better naming

* feat: update the readmes

* fix: typo

* fix: fixing tests [sc-00]

* test: fixes snapshot test [sc-00]
  • Loading branch information
tnolet authored Dec 14, 2023
1 parent 01faf71 commit 48901af
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 175 deletions.
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
The Checkly CLI gives you a **JavaScript/TypeScript-native workflow** for coding, testing and deploying synthetic
monitoring at scale, from your code base. We call this workflow **monitoring as code** (MaC).

- **Unite E2E testing & monitoring in one workflow.** No more silos between Dev, QA and Ops.
- **Codeable, testable, reviewable.** Works with your dev pipeline. From your IDE, via PR to CI.
- **Codeable, testable, reviewable monitoring constructs.** Works with your dev pipeline. From your IDE, via PR to CI.
- **Native `@playwright/test` support.** No lock-in, just write standard `*.spec.ts` files.
- **Alerting baked in.** Set alerts for Slack, SMS and many more channels.
- **Typescript-first.** Fully typed for easy refactoring and code completion.
- **Run in the cloud or on-prem.** Run on the Checkly cloud or in your network using the [Private Locations](https://www.checklyhq.com/docs/private-locations/)

# A quick example

Monitoring checks are written by instantiating constructs from the `checkly/constructs` package...

```ts
// books-api.check.ts
import { ApiCheck, AssertionBuilder } from 'checkly/constructs'

new ApiCheck('books-api-check-1', {
name: 'Books API',
request: {
url: 'https://danube-web.shop/api/books',
method: 'GET',
assertions: [
AssertionBuilder.statusCode().equals(200),
AssertionBuilder.jsonBody('$[0].id').isNotNull(),
],
}
})
```
For browser checks, you can just write standard `*.spec.ts` files using `@playwright/test`.

```ts
// home.spec.ts
import { test, expect } from '@playwright/test'

test('webshop homepage', async ({ page }) => {
const response = await page.goto('https://danube-web.shop')
expect(response?.status()).toBeLessThan(400)
await expect(page).toHaveTitle(/Danube WebShop/)
await page.screenshot({ path: 'homepage.jpg' })
})
```

Run your checks from your local machine or in CI using `npx checkly test`

```bash
npx checkly test
Parsing your project... done

Running 2 checks in eu-west-1.

__checks__/books-api.check.ts
✔ Books API 1 (52ms)
__checks__/home.spec.ts
✔ home.spec.ts (5s)

2 passed, 2 total
```

Now deploy your checks to the Checkly cloud so they can monitor your apps and APIs around the clock and alert you when things break.

```bash
npx checkly deploy

Parsing your project... done
Successfully deployed project "Acme webapp" to account "Acme Production".
```

# Installation

Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-project-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm create checkly -- --template advanced-project

## Project Structure

This project mimics a typical app where you organize code with top-level defaults and per page, service or component checks.
This project has examples of all Checkly check types and showcases some advanced features. It also adds a GitHub Actions workflow.

- Running `npx checkly test` will look for `.check.js` files and `.spec.js` in `__checks__` directories and execute them in a dry run.

Expand Down Expand Up @@ -42,7 +42,7 @@ You can add `@playwright/test` to this project to get full code completion and r
It's best to install the Playwright npm package version that matches your [Checkly runtime](https://www.checklyhq.com/docs/cli/npm-packages/).

```bash
npm install --save-dev @playwright/test@1.28.0
npm install --save-dev @playwright/test@1.38.1
```

## Questions?
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-project-js/src/__checks__/api.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require('path');
const { ApiCheck, AssertionBuilder } = require('checkly/constructs');
const { websiteGroup } = require('./website-group.check');

new ApiCheck('homepage-api-check-1', {
name: 'Fetch Book List',
new ApiCheck('books-api-check-1', {
name: 'Books API',
group: websiteGroup,
degradedResponseTime: 10000,
maxResponseTime: 20000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { test, expect } = require('@playwright/test');
// You can override the default Playwright test timeout of 30s
// test.setTimeout(60000);

test('Checkly Homepage', async ({ page }) => {
test('webshop homepage', async ({ page }) => {
await page.setViewportSize(defaults.playwright.viewportSize);
const response = await page.goto(defaults.pageUrl);

Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions examples/advanced-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm create checkly -- --template advanced-project

## Project Structure

This project mimics a typical app where you organize code with top-level defaults and per page, service or component checks.
This project has examples of all Checkly check types and showcases some advanced features. It also adds a GitHub Actions workflow.

- Running `npx checkly test` will look for `.check.ts` files and `.spec.ts` in `__checks__` directories and execute them in a dry run.

Expand Down Expand Up @@ -42,7 +42,7 @@ You can add `@playwright/test` to this project to get full code completion and r
It's best to install the Playwright npm package version that matches your [Checkly runtime](https://www.checklyhq.com/docs/cli/npm-packages/).

```bash
npm install --save-dev @playwright/test@1.28.0
npm install --save-dev @playwright/test@1.38.1
```

## Questions?
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-project/src/__checks__/api.check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from 'path'
import { ApiCheck, AssertionBuilder } from 'checkly/constructs'
import { websiteGroup } from './website-group.check'

new ApiCheck('homepage-api-check-1', {
name: 'Fetch Book List',
new ApiCheck('books-api-check-1', {
name: 'Books API',
group: websiteGroup,
degradedResponseTime: 10000,
maxResponseTime: 20000,
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced-project/src/__checks__/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defaults } from '../defaults'
// You can override the default Playwright test timeout of 30s
// test.setTimeout(60_000)

test('Checkly Homepage', async ({ page }) => {
test('webshop homepage', async ({ page }) => {
await page.setViewportSize(defaults.playwright.viewportSize)
const response = await page.goto(defaults.pageUrl)

Expand Down
41 changes: 0 additions & 41 deletions examples/advanced-project/src/services/api/__checks__/api.check.ts

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion examples/boilerplate-project-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You can add `@playwright/test` to this project to get full code completion and r
It's best to install the Playwright npm package version that matches your [Checkly runtime](https://www.checklyhq.com/docs/cli/npm-packages/).

```bash
npm install --save-dev @playwright/test@1.28.0
npm install --save-dev @playwright/test@1.38.1
```

## Questions?
Expand Down
4 changes: 2 additions & 2 deletions examples/boilerplate-project-js/__checks__/api.check.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { ApiCheck, AssertionBuilder } = require("checkly/constructs");

new ApiCheck("homepage-api-check-1", {
name: "Fetch Book List",
new ApiCheck("books-api-check-1", {
name: "Books API",
alertChannels: [],
degradedResponseTime: 10000,
maxResponseTime: 20000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { test, expect } = require('@playwright/test');
// You can override the default Playwright test timeout of 30s
// test.setTimeout(60_000);

test('Checkly Homepage', async ({ page }) => {
test('webshop homepage', async ({ page }) => {
const response = await page.goto('https://danube-web.shop');
expect(response?.status()).toBeLessThan(400);
await expect(page).toHaveTitle(/Danube WebShop/);
Expand Down
2 changes: 1 addition & 1 deletion examples/boilerplate-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You can add `@playwright/test` to this project to get full code completion and r
It's best to install the Playwright npm package version that matches your [Checkly runtime](https://www.checklyhq.com/docs/cli/npm-packages/).

```bash
npm install --save-dev @playwright/test@1.28.0
npm install --save-dev @playwright/test@1.38.1
```

## Questions?
Expand Down
4 changes: 2 additions & 2 deletions examples/boilerplate-project/__checks__/api.check.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiCheck, AssertionBuilder } from 'checkly/constructs'

new ApiCheck('homepage-api-check-1', {
name: 'Fetch Book List',
new ApiCheck('books-api-check-1', {
name: 'Books API',
alertChannels: [],
degradedResponseTime: 10000,
maxResponseTime: 20000,
Expand Down
2 changes: 1 addition & 1 deletion examples/boilerplate-project/__checks__/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test, expect } from '@playwright/test'
// You can override the default Playwright test timeout of 30s
// test.setTimeout(60_000);

test('Checkly Homepage', async ({ page }) => {
test('webshop homepage', async ({ page }) => {
const response = await page.goto('https://danube-web.shop')
expect(response?.status()).toBeLessThan(400)
await expect(page).toHaveTitle(/Danube WebShop/)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/cli/e2e/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('test', () => {
it('Should run snapshot tests', async () => {
const secretEnv = uuid.v4()
const result = await runChecklyCli({
args: ['test', '-e', `SECRET_ENV=${secretEnv}`, '--verbose'],
args: ['test', '-e', `SECRET_ENV=${secretEnv}`, '--verbose', '--record'],
apiKey: config.get('apiKey'),
accountId: config.get('accountId'),
directory: path.join(__dirname, 'fixtures', 'snapshot-project'),
Expand Down
Loading

0 comments on commit 48901af

Please sign in to comment.