Monday, 15 June 2015

node.js - How do I launch server for multiple mocha chai-http test files? -


I'm starting my node server before block on my Mocha Tea-HT check.

I am doing the right thing for single test files, however, when I try to run multiple tests in a single command then NODE_ENV = test mocha test / ** / *. Js I get an error.

I tried to keep the node, the server launches on different ports in the test file. It did not work, found node server start errors

Now I'm thinking that it would be great if I have a single MOA file that runs before running other servers before my other test files and Then after a second file that hits the other test files / stop the server.

How do I go about this?

Below I have some code:

Here is a test file for reference:

  var chai = require ('chai'); Var chaiHttp = Expected ('Tea-HP'); Chai.use (chaiHttp); Expecting Var = chai.expect; Var Seal = is required ('seal'); ('REST user API', function () {var app}, log in to the start and stop seal server before {Sails.lift ({port: 3001}: {level: 'error '}}, Function (_err, _sails) {if (_RR) {console.log ("error!", _RR); done ();} else {app = _sails.hooks.http};) () () ) () () () ();} ();}}};}}; Description ("user session", function () {var res; // http response var authenticatedUser; before (function (done) {chai.request app). Post ('/ user / signin') .set ('accept' Submit ('content-type', 'app / jason'). ({Email: 'admin@ test .com', password: 'secret'}) .end (function (_res) { Enter the response to the test = _res; // test. Authenticated user = JSON.parse (_res.text); // Save the response to user authenticated tested ();});}); It should "join with 200 position", function () {hope (rec) .to.have.status (200);}); This is ("must be a complete user session", function () {var userSession = authenticatedUser; hopefully (user session) .to.have.property ('firstName'); Hopefully (user session) .to.have.property (User session) .to.have.property ('gender'); expectation (user session) .to.have.property ('locale'); expectation (user session) .to.have.property ('Timezone'); hope (user session) .to.have.property ('picture'); expected (user session) .to.have.property ('call'); expect (user session) .to.have Property ('email'); hope (umm Door (user session); to.have.property (user session) .to.have.property ('confirmation'); Expected (user session) .to.have.property ('position'); Expected (user session) To.have.property ('authToken');});}); After (function (done) {sails.lower (function () {done ()})}); });  


No comments:

Post a Comment