From c88f262c77a254423f2bc775f7cf29c5b4044a07 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Fri, 16 Aug 2024 17:10:45 +0530 Subject: [PATCH 1/3] feat: added documentation for templatize Signed-off-by: Pranshu Srivastava --- .../running-keploy/cli-commands.md | 9 +++++ .../running-keploy/keploy-templatize.md | 37 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md diff --git a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md index fa14f96a..648801ef 100755 --- a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md +++ b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md @@ -295,6 +295,15 @@ The `rerecord`cmd allow user to record new keploy testcases/mocks from the exist keploy rerecord -c "node src/app.js" -t "test-set-0" ``` +## [templatize](#templatize) +The `templatize` cmd allows the user to templatize important fields in the testcases who's values are used in the request of testcases and that may change in the future. + + Usage: + +```bash +keploy templatize [flags] +``` + ## [config](#config) The `config` command in Keploy is used to generate the Keploy Configuration File i.e. `keploy.yaml`. The generated configuration file is created in the current working directory. diff --git a/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md b/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md new file mode 100644 index 00000000..5b610169 --- /dev/null +++ b/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md @@ -0,0 +1,37 @@ +--- +id: keploy-templatize +title: Keploy Templatize +sidebar_label: Keploy Templatize +description: This section documents how to templatize a testset +tags: + - keploy + - keploy templatize +keywords: + - keploy + - documentation + - running-guide +--- + +Sometimes keploy test and keploy rerecord fail because there are fields which are noisy but they are used in requests so when their values change, the subsequent requests also fail. + +eg: If an application is returning a JWT token in the response of a testcase and that token is being used in the request of another testcase, then that testcase will also fail when a new token is issued and the test is still using the old one that has been expired. + +Templatize, as its name suggests, templatizes the testcases, so now the JWT token's original value will be replaced by a template in both the response of one testcase and the request of the other testcase and a config file will be created which will contain a map of the template key mapped to its value. Now in the test mode or rerecord mode, whenever a new token is issued where the template is placed, it will update the template value in the map and use that value in the subequent testcases where the template is placed. + +## Keploy Templatize Example + +You can use the following command to templatize your testsets. + +```zsh +sudo -E env 'PATH=$PATH' keploy templatize +``` + +By default, it templatizes all the testsets in the keploy folder. If you want to templatize a particular testset, you can pass the testset flag like + +```zsh +sudo -E env 'PATH=$PATH' keploy templatize -t="test-set-1" +``` + +> **Note** +> +> Even though you can use templatize multiple times, even on testsets that have already been templatized, but it is not reversible. So make sure you create a copy of your keploy folder before trying it out. From 2747fe6df415f319680f5c7a4964d819feb7c0fd Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Fri, 16 Aug 2024 17:10:45 +0530 Subject: [PATCH 2/3] feat: added documentation for templatize Signed-off-by: Pranshu Srivastava --- .../running-keploy/cli-commands.md | 10 +++++ .../running-keploy/keploy-templatize.md | 37 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md diff --git a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md index fa14f96a..836239ac 100755 --- a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md +++ b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md @@ -295,6 +295,16 @@ The `rerecord`cmd allow user to record new keploy testcases/mocks from the exist keploy rerecord -c "node src/app.js" -t "test-set-0" ``` +## [templatize](#templatize) + +The `templatize` cmd allows the user to templatize important fields in the testcases who's values are used in the request of testcases and that may change in the future. + + Usage: + +```bash +keploy templatize [flags] +``` + ## [config](#config) The `config` command in Keploy is used to generate the Keploy Configuration File i.e. `keploy.yaml`. The generated configuration file is created in the current working directory. diff --git a/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md b/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md new file mode 100644 index 00000000..5b610169 --- /dev/null +++ b/versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md @@ -0,0 +1,37 @@ +--- +id: keploy-templatize +title: Keploy Templatize +sidebar_label: Keploy Templatize +description: This section documents how to templatize a testset +tags: + - keploy + - keploy templatize +keywords: + - keploy + - documentation + - running-guide +--- + +Sometimes keploy test and keploy rerecord fail because there are fields which are noisy but they are used in requests so when their values change, the subsequent requests also fail. + +eg: If an application is returning a JWT token in the response of a testcase and that token is being used in the request of another testcase, then that testcase will also fail when a new token is issued and the test is still using the old one that has been expired. + +Templatize, as its name suggests, templatizes the testcases, so now the JWT token's original value will be replaced by a template in both the response of one testcase and the request of the other testcase and a config file will be created which will contain a map of the template key mapped to its value. Now in the test mode or rerecord mode, whenever a new token is issued where the template is placed, it will update the template value in the map and use that value in the subequent testcases where the template is placed. + +## Keploy Templatize Example + +You can use the following command to templatize your testsets. + +```zsh +sudo -E env 'PATH=$PATH' keploy templatize +``` + +By default, it templatizes all the testsets in the keploy folder. If you want to templatize a particular testset, you can pass the testset flag like + +```zsh +sudo -E env 'PATH=$PATH' keploy templatize -t="test-set-1" +``` + +> **Note** +> +> Even though you can use templatize multiple times, even on testsets that have already been templatized, but it is not reversible. So make sure you create a copy of your keploy folder before trying it out. From 65af74dc228220fb20844bf0e9334b82f8f30048 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Fri, 23 Aug 2024 12:46:27 +0530 Subject: [PATCH 3/3] fix: added the change in versioned sidebars Signed-off-by: Pranshu Srivastava --- .../version-2.0.0/running-keploy/cli-commands.md | 1 + versioned_sidebars/version-2.0.0-sidebars.json | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md index 648801ef..836239ac 100755 --- a/versioned_docs/version-2.0.0/running-keploy/cli-commands.md +++ b/versioned_docs/version-2.0.0/running-keploy/cli-commands.md @@ -296,6 +296,7 @@ keploy rerecord -c "node src/app.js" -t "test-set-0" ``` ## [templatize](#templatize) + The `templatize` cmd allows the user to templatize important fields in the testcases who's values are used in the request of testcases and that may change in the future. Usage: diff --git a/versioned_sidebars/version-2.0.0-sidebars.json b/versioned_sidebars/version-2.0.0-sidebars.json index 0429e4f7..4a976feb 100644 --- a/versioned_sidebars/version-2.0.0-sidebars.json +++ b/versioned_sidebars/version-2.0.0-sidebars.json @@ -27,7 +27,8 @@ "running-keploy/rename-testcases", "running-keploy/docker-tls", "running-keploy/configuration-file", - "running-keploy/custom-mocks" + "running-keploy/custom-mocks", + "running-keploy/keploy-templatize" ] }, { @@ -81,7 +82,6 @@ "quickstart/samples-redis", "quickstart/samples-mux", "quickstart/samples-mysql", - "quickstart/samples-sse", "quickstart/samples-fasthttp" ] }, @@ -107,8 +107,7 @@ "quickstart/samples-nextjs", "quickstart/samples-nodejs", "quickstart/samples-node-jwt", - "quickstart/crud-nodejs", - "quickstart/express-mongoose-application" + "quickstart/crud-nodejs" ] }, {