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
Copy file name to clipboardExpand all lines: README.md
+52-7Lines changed: 52 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,9 @@ Pythagora records all requests to endpoints of your app with the response and ev
42
42
<b>NOTES: </b>
43
43
- to stop the capture, you can exit the process like you usually do (Eg. `Ctrl + C`)
44
44
- on Windows make sure to run all commands using `Git Bash` and not `Power Shell` or anything similiar
45
-
<br>
45
+
46
+
<br>
47
+
<br>
46
48
<h1 id="executingtests">▶️ Running tests</h1>
47
49
When running tests, it doesn’t matter what database is your Node.js connected to or what is the state of that database. Actually, that database is never touched or used —> instead, Pythagora creates a special, ephemeral pythagoraDb database, which it uses to restore the data before each test is executed, which was present at the time when the test was recorded. Because of this, tests can be run on any machine or environment.
48
50
@@ -55,6 +57,20 @@ So, after you captured all requests you want, you just need to change the mode p
55
57
```
56
58
57
59
<br><br>
60
+
<h1 id="exportjest">🗄️ Export tests to Jest</h1>
61
+
If you want to export recorded Pythagora tests to Jest tests so you can more easily read and edit them you can do so by running this command:
62
+
63
+
```bash
64
+
npx pythagora --export
65
+
```
66
+
If you don't have recorded login endpoint it will ask you to run:
67
+
68
+
```bash
69
+
npx pythagora --export-setup
70
+
```
71
+
after which you just have to run capture command again and go to endpoint login. Once that is done you are ready to export your tests to Jest.
72
+
<br>
73
+
<br>
58
74
<h1 id="demo">🎞 Demo</h1>
59
75
60
76
Here are some demo videos that can help you get started.
@@ -191,10 +207,42 @@ That's it! You are ready to go and all your API requests with authentication sho
191
207
192
208
<br><br>
193
209
<h1 id="testdata">🗺️️ Where can I see the tests?</h1>
194
-
Each captured test is saved in<strong><i>pythagora_tests</i></strong> directory at the root of your repository.
210
+
Each captured test is saved in <strong><i>"pythagora_tests"</i></strong> directory at the root of your repository.
211
+
<br><br>
212
+
<details><summary style="background-color: grey; padding: 10px; border: none; border-radius: 4px; cursor: pointer;">Click here to see "pythagora_tests" folder structure explanation:</summary>
213
+
214
+
<ul>
215
+
<li>pythagora_tests
216
+
<ul>
217
+
<li>exported_tests <span style="color: green;">// folder containing all exported Jest tests</span>
218
+
<ul>
219
+
<li>data <span style="color: green;">// folder containing Jest test data</span>
220
+
<ul>
221
+
<li>JestTest1.json <span style="color: green;">// this is data that is populated in DB for JestTest1.test.js</span></li>
222
+
<li>JestTest2.json <span style="color: green;">// this is data that is populated in DB for JestTest2.test.js</span></li>
223
+
<li>...</li>
224
+
</ul>
225
+
</li>
226
+
<li>auth.js <span style="color: green;">// here is authentication function that is used in all Jest tests</span></li>
227
+
<li>global-setup.js</li>
228
+
<li>JestTest1.test.js <span style="color: green;">// this is an exported Jest test</span></li>
229
+
<li>JestTest2.test.js</li>
230
+
<li>...</li>
231
+
</ul>
232
+
</li>
233
+
<li>pythagoraTest1.json <span style="color: green;">// this is a Pythagora test</span></li>
234
+
<li>pythagoraTest2.json</li>
235
+
<li>...</li>
236
+
</ul>
237
+
</li>
238
+
</ul>
239
+
</details>
240
+
<br><br>
195
241
Each JSON file in this repository represents one endpoint that was captured and each endpoint can have many captured tests.
196
242
If you open these files, you will see an array in which each object represents a single test. All data that's needed to run a test
197
243
is stored in this object. Here is an example of a test object.
244
+
<br><br>
245
+
<details><summary style="background-color: grey; padding: 10px; border: none; border-radius: 4px; cursor: pointer;">Click here to see example of one recorded Pythagora test:</summary>
198
246
199
247
```json
200
248
{
@@ -258,11 +306,8 @@ is stored in this object. Here is an example of a test object.
258
306
"createdAt": "2023-02-22T14:57:52.362Z" // date when the test was captured
259
307
}
260
308
```
261
-
<b>NOTE:</b> If you used Pythagora version < 0.0.39 tests were stored in files with delimiter "|" and since we added Windows support that is changed to "-_-".
262
-
To update all your tests to work with new version of Pythagora run:
0 commit comments