| Title: | Test R Web Applications |
| Version: | 1.0.0 |
| Description: | Write so-called 'Integration Tests' for your R web applications by declaring an HTTP request and the expectations its response should meet. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 8.0.0 |
| Imports: | httpuv, nanonext (≥ 1.10.1), R6, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Suggests: | routing, yyjsonr |
| URL: | https://github.com/JulioCollazos64/mochita |
| BugReports: | https://github.com/JulioCollazos64/mochita/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-07-29 04:03:52 UTC; julio |
| Author: | Julio Collazos [aut, cre], supertest contributors [ctb, cph] (authors listed in <https://github.com/forwardemail/supertest/graphs/contributors>) |
| Maintainer: | Julio Collazos <amarullazo626@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-06 13:40:02 UTC |
mochita: 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.
Author(s)
Maintainer: Julio Collazos amarullazo626@gmail.com
Authors:
Julio Collazos amarullazo626@gmail.com
Other contributors:
supertest contributors (authors listed in <https://github.com/forwardemail/supertest/graphs/contributors>) [contributor, copyright holder]
See Also
Useful links:
Report bugs at https://github.com/JulioCollazos64/mochita/issues
Test an HTTP server
Description
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().
Usage
mochita(app)
Arguments
app |
App definition, see httpuv::startServer. |
Value
A Mochita R6 class object.
Mochita Methods
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.
Examples
## Not run:
mochita(app)$get("/")$
set("Accept", "text/plain")$
expect(200)$
expect("Content-Type", "text/plain")$
perform()
## End(Not run)