-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Test "invalidates assertion (known type)" fails when run on Node 6.5.0 as per travis build https://travis-ci.org/hapijs/code
fails because nodes util.inspect has changed it's return value for the code const Custom = function () { };
"use strict";
const Custom = function () { };
const NodeUtil = require("util");
console.log(NodeUtil.inspect(new Custom()));v4.4.7 returns {}
v6.4.0 returns {}
v6.5.0 returns Custom {}
My guess is that the other issues are similar but I haven't drilled down into them yet.
As proof, the following does work
it('invalidates assertion (known type)', (done) => {
const Custom = function () { };
Custom.prototype.inspect = function () {
return '{}';
};
let exception = false;
try {
Code.expect(new Custom()).to.be.an.error(Error);
}
catch (err) {
exception = err;
}
Hoek.assert(exception.message === 'Expected {} to be an error with Error type', exception);
done();
});or by assuming that Node can be fickle and just changing the expectation to be
const customInspection = NodeUtil.inspect(new Custom());
Hoek.assert(exception.message === `Expected ${customInspection} to be an error with Error type`, exception);With the important difference being the custom inspect method on the Custom prototype. I don't mind helping out with fixing the errors but what do you want the output to be?
I think that Custom {} is better than {} in which case how about we just change the assertion to check for the string with the include node generated inspect string as above.