Skip to content

Commit cce86d8

Browse files
feat: added documentation for templatize (#446)
* feat: added documentation for templatize Signed-off-by: Pranshu Srivastava <[email protected]> * feat: added documentation for templatize Signed-off-by: Pranshu Srivastava <[email protected]> * fix: added the change in versioned sidebars Signed-off-by: Pranshu Srivastava <[email protected]> --------- Signed-off-by: Pranshu Srivastava <[email protected]> Co-authored-by: Animesh Pathak <[email protected]>
1 parent 9bb8914 commit cce86d8

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

versioned_docs/version-2.0.0/running-keploy/cli-commands.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ The `rerecord`cmd allow user to record new keploy testcases/mocks from the exist
295295
keploy rerecord -c "node src/app.js" -t "test-set-0"
296296
```
297297

298+
## [templatize](#templatize)
299+
300+
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.
301+
302+
<b> Usage: </b>
303+
304+
```bash
305+
keploy templatize [flags]
306+
```
307+
298308
## [config](#config)
299309

300310
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.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: keploy-templatize
3+
title: Keploy Templatize
4+
sidebar_label: Keploy Templatize
5+
description: This section documents how to templatize a testset
6+
tags:
7+
- keploy
8+
- keploy templatize
9+
keywords:
10+
- keploy
11+
- documentation
12+
- running-guide
13+
---
14+
15+
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.
16+
17+
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.
18+
19+
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.
20+
21+
## Keploy Templatize Example
22+
23+
You can use the following command to templatize your testsets.
24+
25+
```zsh
26+
sudo -E env 'PATH=$PATH' keploy templatize
27+
```
28+
29+
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
30+
31+
```zsh
32+
sudo -E env 'PATH=$PATH' keploy templatize -t="test-set-1"
33+
```
34+
35+
> **Note**
36+
>
37+
> 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.

versioned_sidebars/version-2.0.0-sidebars.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"running-keploy/rename-testcases",
2828
"running-keploy/docker-tls",
2929
"running-keploy/configuration-file",
30-
"running-keploy/custom-mocks"
30+
"running-keploy/custom-mocks",
31+
"running-keploy/keploy-templatize"
3132
]
3233
},
3334
{
@@ -77,7 +78,6 @@
7778
"quickstart/samples-redis",
7879
"quickstart/samples-mux",
7980
"quickstart/samples-mysql",
80-
"quickstart/samples-sse",
8181
"quickstart/samples-fasthttp"
8282
]
8383
},
@@ -103,8 +103,7 @@
103103
"quickstart/samples-nextjs",
104104
"quickstart/samples-nodejs",
105105
"quickstart/samples-node-jwt",
106-
"quickstart/crud-nodejs",
107-
"quickstart/express-mongoose-application"
106+
"quickstart/crud-nodejs"
108107
]
109108
},
110109
{

0 commit comments

Comments
 (0)