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

feat: added documentation for templatize #446

Merged
merged 6 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Sonichigo marked this conversation as resolved.
Show resolved Hide resolved
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
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have images showing how after the templatize feature would look like

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the images in the PR description.


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.
Loading