dero
dero copied to clipboard
Unit / Integration test with Dero
This framework looks like there is a lot of batteries already included, but I didn't saw any way for testing this framework,
How can I unit or integrate test with this framework?
Thanks for creating issue. I think superdeno is a great library for testing the Rest API. below example with Dero.
import { BaseController, Controller, Dero, Get } from "https://deno.land/x/[email protected]/mod.ts";
import { superdeno } from "https://deno.land/x/[email protected]/mod.ts";
@Controller("/user")
class UserController extends BaseController {
@Get()
getUser() {
return "Hello";
}
}
class Application extends Dero {
constructor() {
super();
this.use({ class: [UserController] });
}
}
const app = new Application();
const handle = (request: Request) => app.handleEvent({ request });
Deno.test("Test App", async () => {
await superdeno(handle)
.get("/user")
.expect("Hello");
});
Run :
deno test -A app_test.ts