GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — updated docs for REST · quantk/codeception.github.com@ad30527

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs
    • 02-GettingStarted.md
    • 03-AcceptanceTests.md
    • 10-APITesting.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/02-GettingStarted.md‎

Copy file name to clipboardExpand all lines: docs/02-GettingStarted.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Learn more about the [Cest format](http://codeception.com/docs/07-AdvancedUsage#
270270
It's hard to write a complete test at once.
271271
You will need to try different commands with different arguments before you find a correct path.
272272

273-
Since Codeception 3.0 you can pause the execution at any point and enter an interactive shell where you will be able to try different commands in action.
273+
Execution can be paused at any point and enter an interactive shell where you will be able to try different commands in action.
274274
All you need to do is **call `$I->pause()`** somewhere in your test, then run the test in [debug mode](#Debugging).
275275

276276
Interactive Pause requires [`hoa/console`](https://hoa-project.net/) which is not installed by default. To install it, run:
Collapse file

‎docs/03-AcceptanceTests.md‎

Copy file name to clipboardExpand all lines: docs/03-AcceptanceTests.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ $I->seeNumberOfElements(['css' => 'button.link'], 5); // DISABLED, can wait only
567567

568568
When it's hard to define condition to wait for, we can retry a command few times until it succeeds.
569569
For instance, if you try to click while it's animating you can try to do it few times until it freezes.
570-
Since Codeception 3.0 each action and assertion have an alias prefixed with `retry` which allows to retry a flaky command.
570+
Each action and assertion have an alias prefixed with `retry` which allows to retry a flaky command.
571571

572572
{% highlight php %}
573573

Collapse file

‎docs/10-APITesting.md‎

Copy file name to clipboardExpand all lines: docs/10-APITesting.md
+20-3Lines changed: 20 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CreateUserCest
8888
'name' => 'davert',
8989
'email' => '[email protected]'
9090
]);
91-
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
91+
$I->seeResponseCodeIsSuccessful();
9292
$I->seeResponseIsJson();
9393
$I->seeResponseContains('{"result":"ok"}');
9494

@@ -97,9 +97,26 @@ class CreateUserCest
9797

9898
{% endhighlight %}
9999

100-
We can use HTTP code constants from `Codeception\Util\HttpCode` instead of numeric values to check response code in `seeResponseCodeIs` and `dontSeeResponseCodeIs` methods.
100+
> New in codeception/module-rest 1.4.1:
101101

102-
Let's see what the test consist of.
102+
If API endpoint accepts JSON you can use a `send` methods with `AsJson` suffix to convert data automatically:
103+
104+
{% highlight php %}
105+
$users = $I->sendGetAsJson('/users');
106+
$I->sendPutAsJson('/users/' . $users[0]['id'], ['name' => 'new name']);
107+
$I->sendDeleteAsJson('/users/' . $users[1]);
108+
109+
{% endhighlight %}
110+
111+
To enable steps with `AsJson` suffix enable `Codeception\Step\AsJson` step decorator in suite config:
112+
113+
```yaml
114+
actor: ApiTester
115+
step_decorators:
116+
- \Codeception\Step\AsJson
117+
```
118+
119+
> `sendGetAsJson`, `sendPutAsJson`, and others, are implemented with a [Step Decorator](https://codeception.com/docs/08-Customization#Step-Decorators). It adds `application/json` Content-Type, checks JSON response and returns JSON response as associative array.
103120

104121
### Authorization
105122

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.