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

Sse docs #438

Merged
merged 12 commits into from
Aug 19, 2024
7 changes: 2 additions & 5 deletions .github/workflows/build_and_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ jobs:
with:
node-version: 18.0.0

- name: Install Yarn
run: npm install -g yarn

- name: Install Dependencies
run: yarn install
run: npm install

- name: Build Documentation
run: yarn build
run: npm run build
8 changes: 8 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ jobs:
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.0.0'

- name: Install Dependencies
run: npm install

- name: Check commits messages
uses: wagoid/commitlint-github-action@v5
env:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ The Keploy documentation site uses [Docusaurus 2](https://v2.docusaurus.io/), wh
You can make changes locally without previewing them in the browser.
However, if you want to build the site and preview changes in the browser, you need to have [Docusaurus 2 dependencies](https://v2.docusaurus.io/docs/installation/#requirements) installed.

Initialize Docusaurus 2 in the repo by running [`yarn`](https://classic.yarnpkg.com/en/docs/cli/) once in the root directory of the repo.
Initialize Docusaurus 2 in the repo by running [`npm`](https://docs.npmjs.com/cli/v7/commands/npm-install) once in the root directory of the repo.

Now you can build and view the site locally:

```bash
yarn start
npm install
npm start
```

The command starts a local development server and opens a browser window.
Expand All @@ -95,17 +96,17 @@ cd docs
3. Install all the dependencies

```sh
yarn install
npm install

## Start the development server.

yarn start
npm start
```

4. To reformat:

```sh
yarn prettier --write '**/*.{js,md}'
npm prettier --write '**/*.{js,md}'
```

5. Check the build status:
Expand Down
38 changes: 37 additions & 1 deletion versioned_docs/version-2.0.0/keploy-explained/docs-dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,30 @@ The Keploy documentation site uses [Docusaurus 2](https://v2.docusaurus.io/), wh
You can make changes locally without previewing them in the browser.
However, if you want to build the site and preview changes in the browser, you need to have [Docusaurus 2 dependencies](https://v2.docusaurus.io/docs/installation/#requirements) installed.

Initialize Docusaurus 2 in the repo by running [`yarn`](https://classic.yarnpkg.com/en/docs/cli/) once in the root directory of the repo.
Initialize Docusaurus 2 in the repo by running [`yarn`](https://classic.yarnpkg.com/en/docs/cli/) or [`npm`](https://docs.npmjs.com/cli/v10) once in the root directory of the repo.

Now you can build and view the site locally:


```shell
npm start
```

or

```shell
yarn start
```


The command starts a local development server and opens a browser window.

## Prettier

**Note: The website has been migrated to use `npm` for building, testing, and deploying.**

Steps 1 to 3 are the same for both `yarn` and `npm`

1. Fork the repository

2. Clone the repository with the following command. Replace the {'<'}GITHUB_USERNAME{'>'} with your username
Expand All @@ -55,6 +67,29 @@ git clone https://github.com/<GITHUB_USERNAME>/docs.git
cd docs
```

### Using `npm`

4. Install all the dependencies

```shell
npm install
```

5. Start the development server.

```shell
npm start
```

6. To reformat:

```shell
npm prettier --write '**/*.{js,md}'
```


### Using `yarn` (Legacy)

4. Install all the dependencies

```shell
Expand All @@ -73,6 +108,7 @@ yarn start
yarn prettier --write '**/*.{js,md}'
```


When we merge your PR, a new build automatically occurs and your changes publish to [https://docs.keploy.io](https://docs.keploy.io).

## How to Contribute Code?
Expand Down
86 changes: 86 additions & 0 deletions versioned_docs/version-2.0.0/quickstart/samples-go-sse-svelte.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
id: samples-sse
title: Sample Real-Time App (Svelte)
sidebar_label: SSE + Svelte + MongoDB
description: The following sample app tests Keploy integration capabilities with realtime subscriptions such as SSE
tags:
- go
- quickstart
- samples
- examples
- tutorial
- svelte
- SSE
keyword:
- Svelte
- Server-Sent Events
- MongoDB Mock
- API Test generator
- Auto Testcase generation
---

## Introduction

🪄 Dive into the world of realtime subscriptions and see how seamlessly Keploy integrates with [SSE](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) and [MongoDB](https://www.mongodb.com/). Buckle up, it's gonna be a fun ride! 🎢

import InstallationGuide from '../concepts/installation.md'

<InstallationGuide/>


## Installation 📥

Ways you can run this sample application.

- [Using Docker container for MongoDB and running application locally](#installation-setup)

## Installation Setup

#### Server
```bash
git clone https://github.com/keploy/samples-go.git && cd samples-go/sse-svelte
go mod download
```

### Start MongoDB Instance
Using the docker-compose file we will start our mongodb instance:-

```bash
# Start Postgres
docker-compose up mongo
```

### Build Application Binary
Now, we will create the binary of our application:-

```bash
go build -cover
```
Once we have our applicaiton binary ready, we will start the application with keploy to start capturing the testcases.

## Capture the test cases
```bash
sudo -E keploy record "./sse-mongo"
```

### Start the UI
We will capture our test from the UI written in Svelte.js
```bash
cd svelte-app && npm install && npm run dev
```

Now let's click on `GetTime` button to trigger the event. We would notice that keploy will capture those calls : -
![Testcases](https://github.com/keploy/samples-go/raw/main/sse-svelte/img/testcase.png?raw=true)

## Run the Testcases
Now let's run the test mode :-

```shell
keploy test -c "./sse-mongo" --delay 10 --goCoverage
```

Output should look like : -

![Testrun](https://github.com/keploy/samples-go/raw/main/sse-svelte/img/testrun.png?raw=true)

So no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to MongoDb 😄**. And with just few clicks we were able to get 42% code coverage of our go backend application.
1 change: 1 addition & 0 deletions versioned_sidebars/version-2.0.0-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"quickstart/samples-redis",
"quickstart/samples-mux",
"quickstart/samples-mysql",
"quickstart/samples-sse",
"quickstart/samples-fasthttp"
]
},
Expand Down
Loading
Loading