I am updating a test case to work with node.js 6.7.0, but I was just told that it may need to support an earlier version of node.js as well, since what is being made available is a package.
The issue is the JSON.parse() method changed its error message along the way. Previously it would indicate something of the form of 'Unexpected token /', but now indicates 'Unexpected token / in JSON at position 4'. This means the line below will work in 6.7.0, but fail with node 4.4.0:
expect(error.message).to.equal('Unexpected token / in JSON at position 4');
How can I test the node.js version to be able to do something like:
if (nodeVersion < 6 /* or whatever version of node it changed at */) {
expect(error.message).to.equal('Unexpected token /');
} else {
expect(error.message).to.equal('Unexpected token / in JSON at position 4');
}
What are common best practices and also what is there a generally minimum version of node.js to be targeting?
Aucun commentaire:
Enregistrer un commentaire