You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, let's setup the `API_KEY` as environment variable:
121
-
122
-
```bash
123
-
export API_KEY=xxxx
124
-
```
125
-
126
-
**Usage:**
127
-
128
-
```bash
129
-
keploy gen [flag]
130
-
```
131
-
132
-
## Command Line Usage Guide
133
-
134
-
### Running with Javascript/TypeScript applications
135
-
136
-
For the we need to make sure that the coverage report is in coberuta format, so to make sure let's modify our `package.json` by adding:
137
-
138
-
```json
139
-
"jest": {
140
-
"coverageReporters": ["text", "cobertura"],
141
-
}
142
-
```
143
-
144
-
or if `jest.config.js` is present then, we need to add:
145
-
146
-
```js
147
-
module.exports= {
148
-
coverageReporters: ["text", "cobertura"],
149
-
};
150
-
```
151
-
152
-
#### Generating Unit Tests
153
-
154
-
You can test a smaller section of application or to control costs, we can consider generating tests for a single source and its corresponding test file:
155
-
156
-
```bash
157
-
keploy gen --source-file-path="<path to source file>" \
158
-
--test-file-path="<path to test file for above source file>" \
159
-
--test-command="npm test" \
160
-
--coverage-report-path="<path to coverage.xml>"
161
-
```
162
-
163
-
For Entire Application we can generate tests by using `--test-dir` instead of `--test-file-path`.
164
-
165
-
> ⚠️ Warning: Executing command with `--test-dir` will generate unit tests for all files in the application. Depending on the size of the codebase, this process may take between 20 minutes to an hour and will incur costs related to LLM usage.
166
-
167
-
#### Example
168
-
169
-
Let us consider the [express-mongoose](https://github.com/keploy/samples-typescript/tree/main/express-mongoose) sample-application, where we have a jest testcases under `test` folder with name `routes.test.js`.
170
-
171
-
We have modified our `package.json` by adding below:
<img src="/docs/img/express-mongoose-utg.png" alt="Keploy test coverage with ai generated unit tests for express-mongoose" width="100%" style={{ borderRadius: '5px' }}/>
194
-
195
-
_Voila!! The Generated Testcases have provided with 58% coverage🌟_
196
-
197
-
### Running with Golang applications
198
-
199
-
To ensure Cobertura formatted coverage reports, we need to install the following:
200
-
201
-
```bash
202
-
go install github.com/axw/gocov/gocov@v1.1.0
203
-
go install github.com/AlekSi/gocov-xml@v1.1.0
204
-
```
205
-
206
-
#### Generating Unit Tests
207
-
208
-
With the above dependecies installed, we can now generate tests for our application by the following dommand:
209
-
210
-
```bash
211
-
keploy gen --source-file-path="<path to source file>o" \
212
-
--test-file-path="<path to test file for above source file>" \
For Entire Application we can generate tests by using `--test-dir` instead of `--test-file-path`.
218
-
219
-
> ⚠️ Warning: Executing command with `--test-dir` will generate unit tests for all files in the application. Depending on the size of the codebase, this process may take between 20 minutes to an hour and will incur costs related to LLM usage.
220
-
221
-
#### Example
222
-
223
-
Let us consider the [mux-sql](https://github.com/keploy/samples-go/tree/main/mux-sql/) sample-application, where we already have our `app_test.go` test file for `app.go` source file:
0 commit comments