You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following test passes if I use 2.1.5, but fails with 2.3. I'm unsure if i'm doing something wrong or not.
var assert = require("assert");
var should = require('should');
var rewire = require('rewire');
var sinon = require('sinon');
var user = rewire('../user');
describe('user', function(){
describe('#buildNumber', function(){
it('should return the value contained in the field "build"', function(){
var rewireRevert = user.__set__({JSON : {
"parse": function()
{
return {"build":"4"};
}}});
var buildNumber = user.buildNumber()
should(buildNumber).be.ok;
buildNumber.should.be.eql("4");
//reset the user object to its original state
rewireRevert();
})
it('should not fail when trying to get the version from the package.json', function(){
var buildNumber = user.buildNumber()
should(buildNumber).be.ok;
})
})
})
The code being tested:
var http = require('http');
var util = require('util');
var fs = require('fs');
function buildNumber()
{
var packageVersion = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8')).build;
//extract the "major" version
return packageVersion;
}
The error returned:
user #buildNumber should return the value contained in the field "build":
TypeError: undefined is not a function
at __set__ (/Users/otusweb/Documents/elektra-liveshare/user.js:149:81)
at /Users/otusweb/Documents/elektra-liveshare/user.js:178:17
at Context.<anonymous> (/Users/otusweb/Documents/elektra-liveshare/test/user.test.js:22:4)
at callFn (/usr/local/lib/node_modules/mocha/lib/runnable.js:251:21)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:244:7)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:452:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:309:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:248:23)
at Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:358:17)
The text was updated successfully, but these errors were encountered:
The following test passes if I use 2.1.5, but fails with 2.3. I'm unsure if i'm doing something wrong or not.
The code being tested:
The error returned:
The text was updated successfully, but these errors were encountered: