From 5a7f55ccf006e4d4aab45d424aac7c17118e8282 Mon Sep 17 00:00:00 2001 From: Ishaanj18 <93217075+Ishaanj18@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:02:05 +0530 Subject: [PATCH] Sse docs (#438) * first commit Signed-off-by: ishaanj18 * added documentation Signed-off-by: ishaanj18 * added changes to version_2.0.0_sidebar.json Signed-off-by: ishaanj18 * updated samples-go-sse-svelte.md Signed-off-by: ishaanj18 * [docs]: Added instructions for using npm to run the Docusaurus site locally (#423) * docs(configuration): added example for handling nested JSON fields Added example for handling nested JSON fields Closes #1892 Signed-off-by: GauriBhandari * docs: add instructions for using npm to run the Docusaurus site locally Added instructions for using npm to run the Docusaurus site locally Closes #2094 Signed-off-by: Gauri Bhandari Signed-off-by: GauriBhandari * docs: add instructions for using npm to run the Docusaurus site locally Added note Closes #2094 Signed-off-by: Gauri Bhandari Signed-off-by: GauriBhandari * Updated documentation to reflect npm migration Revised the documentation to include instructions for using npm instead of yarn Migration from using yarn to npm on docs website Closes #2094 Signed-off-by: Gauri Bhandari Signed-off-by: GauriBhandari * docs: update npm migration instructions Revised the documentation to include instructions for using npm instead of yarn. This change reflects the migration from using yarn to npm for building, testing, and deploying the docs website. Closes #2094 Signed-off-by: GauriBhandari * ci: update lint.yml to ensure proper commit message formatting This commit updates the lint.yml file to ensure that commit messages follow the required format. Closes #2094 Signed-off-by: Gauri Bhandari Signed-off-by: GauriBhandari * docs: update npm migration instructions Closes #2094 Signed-off-by: Gauri Bhandari Signed-off-by: GauriBhandari * docs: update installation instructions for npm migration Revised the documentation to reflect the migration from Yarn to npm for building, testing, and deploying the docs website. Closes #2094 Signed-off-by: GauriBhandari --------- Signed-off-by: GauriBhandari Co-authored-by: Animesh Pathak --------- Signed-off-by: ishaanj18 Signed-off-by: Animesh Pathak Signed-off-by: Gauri Bhandari Co-authored-by: Animesh Pathak Co-authored-by: Gauri Bhandari <123401864+GauriBhandari@users.noreply.github.com> Co-authored-by: Animesh Pathak --- .../keploy-explained/docs-dev-guide.md | 6 ++ .../quickstart/samples-go-sse-svelte.md | 93 +++++++++++++++++++ .../version-2.0.0-sidebars.json | 1 + 3 files changed, 100 insertions(+) create mode 100644 versioned_docs/version-2.0.0/quickstart/samples-go-sse-svelte.md diff --git a/versioned_docs/version-2.0.0/keploy-explained/docs-dev-guide.md b/versioned_docs/version-2.0.0/keploy-explained/docs-dev-guide.md index c7bd70c7..2d43aae6 100644 --- a/versioned_docs/version-2.0.0/keploy-explained/docs-dev-guide.md +++ b/versioned_docs/version-2.0.0/keploy-explained/docs-dev-guide.md @@ -39,6 +39,12 @@ npm start or +```shell +npm start +``` + +or + ```shell yarn start ``` diff --git a/versioned_docs/version-2.0.0/quickstart/samples-go-sse-svelte.md b/versioned_docs/version-2.0.0/quickstart/samples-go-sse-svelte.md new file mode 100644 index 00000000..67090c93 --- /dev/null +++ b/versioned_docs/version-2.0.0/quickstart/samples-go-sse-svelte.md @@ -0,0 +1,93 @@ +--- +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' + + + +## 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. diff --git a/versioned_sidebars/version-2.0.0-sidebars.json b/versioned_sidebars/version-2.0.0-sidebars.json index e383518c..8b31cfba 100644 --- a/versioned_sidebars/version-2.0.0-sidebars.json +++ b/versioned_sidebars/version-2.0.0-sidebars.json @@ -81,6 +81,7 @@ "quickstart/samples-redis", "quickstart/samples-mux", "quickstart/samples-mysql", + "quickstart/samples-sse", "quickstart/samples-fasthttp" ] },