Variable implementConst

implement: Macro<[HttpMethod, boolean?], IContext> = ...

Test that resource handle method.

This is a test macro. It can be used to test handling any HTTP method supported by SuperAgent.

Example use of this test in typescript:

import anyTest, { TestInterface } from "ava";
import express from "express";
import superTest from "supertest";

import * as restHALTestTools from "@yeiniel/rest-hal-test-tools";

const test = anyTest as TestInterface<restHALTestTools.IContext>;

test.beforeEach((t) => {
const app = express();

// provide an endpoint handler for the GET method
app.get("/", (_, res) => { res.end(); });
app.post("/", (_, res) => { res.status(405).end(); });

t.context.agent = superTest(app);
t.context.resource = "/";
});

// resource handle get requests
test(restHALTestTools.implement, "get");

// resource do not handle post requests
test(restHALTestTools.implement, "post", false);

Param

Test execution context

Param

Http method

Param

Whether it is expected or not that resource handle method (true by default)

Generated using TypeDoc