Skip to content

Commit

Permalink
feat: added documentation for templatize
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
PranshuSrivastava authored and actions-user committed Aug 16, 2024
1 parent eea73cc commit 2747fe6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions versioned_docs/version-2.0.0/running-keploy/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<b> Usage: </b>

```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.
Expand Down
37 changes: 37 additions & 0 deletions versioned_docs/version-2.0.0/running-keploy/keploy-templatize.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 2747fe6

Please sign in to comment.