| Title: | Test R Web Applications |
|---|---|
| Description: | Write so-called 'Integration Tests' for your R web applications by declaring an HTTP request and the expectations its response should meet. |
| Authors: | Julio Collazos [aut, cre], supertest contributors [ctb, cph] (authors listed in <https://github.com/forwardemail/supertest/graphs/contributors>) |
| Maintainer: | Julio Collazos <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-09-22 11:04:18 UTC |
| Source: | https://github.com/juliocollazos64/mochita |
mochita() builds the specification for testing an httpuv app.
It returns a Mochita object whose methods can be chained together
to build up a request, describe the expectations it
should meet, and finally send it with $perform().
mochita(app)mochita(app)
app |
App definition, see httpuv::startServer. |
A Mochita R6 class object.
A Mochita is an R6 Class with the following methods:
$get(path), $head(path), $post(path), $put(path),
$delete(path), $connect(path), $options(path), $trace(path),
$patch(path) Set the HTTP Method and path of the request.
$set(name,value) Set a request header.
$expect() Add an expectation to check against the response,
once performed. Accepts a status code (optionally with a body to match),
a header name/value pair, a body to match, or a custom function taking
the response.
$perform() Send the request and run the recorded expectations against
the response.
## Not run: mochita(app)$get("/")$ set("Accept", "text/plain")$ expect(200)$ expect("Content-Type", "text/plain")$ perform() ## End(Not run)## Not run: mochita(app)$get("/")$ set("Accept", "text/plain")$ expect(200)$ expect("Content-Type", "text/plain")$ perform() ## End(Not run)