Nodejs / express testing

I am writing an application with an expression.

The main file is called server.js

one of the objects

var app = express.createServer(express.logger(),
    express.bodyDecoder());

then i have

app.get("/",function(req, res){
  res.send("Running");
}

How to use expresso, [or any other testing framework for this stuff] to check the route output?

I looked at the express website, but could not understand how to get it so that everyone would work together, is it possible if someone gave me a short example?

Thank!

+3
source share
2 answers

I'm sure you found the answer to this question, but you tried something like this:

assert.response(server, {
    url: '/',
    method: 'GET'
},{
    body: '{"name":"tj"}',
    status: 200,
    headers: {
        'Content-Type': 'application/json; charset=utf8',
        'X-Foo': 'bar'
    }
});
+2
source

Node.js :

Expresso Mocha. Mocha HTTP-, Request, SuperTest, zombie.js ..

Zombie.js , , . w/cookies cookie. " : , cookie, HTML5 .."

+1

Source: https://habr.com/ru/post/1764815/


All Articles