I've found examples how to test querry parameters e.g.:
/api/browser?parameter1=2341¶meter2=5663
but I could't find how to parametrize a test if I've a path parameter, an URL like this:
const ENDPOINT_DETAILS = "/api/browser/:parameter";
app.get(ENDPOINT_DETAILS, function (req, res) {
logger.info("Endpoint called: " + ENDPOINT_DETAILS);
var details = {}
// ... magic
res.send(details);
}
How should my test look like if I don't want to fix my parameter?
describe("returns details", function() {
it("returns status 200", function(done) {
var sampleData = "sample_detail";
// this won't work
restApi.get('/api/browser/:parameter')
.set('Accept', 'application/json')
.expect(200, { "text" : "Detail of " + parameter + " is: " + sample_text})
.end(function(err, res) {
if (err) throw err;
done();
});
});
});
Is it possible to know the value of the parameter
here, before restApi.get()
is called?
Aucun commentaire:
Enregistrer un commentaire