I to be trying to specify some endpoints and also do a test using nodejs. In server.js i have:

var express = require('express'); var func1 = require('./func1.js'); var harbor = 8080; var server = express(); server.configure(function() server.use(express.bodyParser()); ); server.post('/testend/', func1.testend); and in func1.js:

var testend = function(req, res) serialPort.write("1", function(err, results) serialPort.write("2" + " ", function(err, results) ); ); ); exports.testend = testend; Now in test.js ns am trying to usage this endpoint:

var need to = require('should'); var assert = require('assert'); var request = require('supertest'); var http = require('http'); var application = require('./../server.js'); var harbor = 8080; describe('Account', function() var url = "http://localhost:" + port.toString(); it('test starts', function(done) request(url).post('/testend/') // finish handles the response .end(function(err, res) if (err) throw err; res.body.error.should.type('string'); done(); ); ); ); But when I operation node test.js i am gaining this error:

describe("Account", function() {^ReferenceError: describe is not characterized at Object. (/test/test.js:9:1) in ~ Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3How have the right to I deal with the issue?


price - 1
0 arrow_circle_up 0 arrow_circle_down

To run tests through node/npm there is no installing Mocha globally, you deserve to do this:

• download Mocha locally to your project (npm install mocha --save-dev)

• Optionally install an assertion library (npm download chai --save-dev)

• In your package.json, add a section for scripts and also target the mocha binary

"scripts": "test": "node ./node_modules/mocha/bin/mocha" • placed your spec records in a magazine named /test in your root directory

• In her spec files, income the delinquent library

var suppose = require('chai').expect; • friend don"t have to import mocha, run mocha.setup, or contact mocha.run()