Test runner: Detect extra property in 'actual' but not in 'expected'. (#407)
* Test runner: Detect extra property in 'actual' but not in 'expected'. Also update all expected.json where this would result in errors. * Include rmExpected.js script in case it is needed again
This commit is contained in:
@@ -49,9 +49,6 @@ exports.runThrowTestsWithEstree = function runThrowTestsWithEstree(fixturesPath,
|
||||
};
|
||||
|
||||
function save(test, ast) {
|
||||
delete ast.tokens;
|
||||
if (ast.comments && !ast.comments.length) delete ast.comments;
|
||||
|
||||
// Ensure that RegExp are serialized as strings
|
||||
const toJSON = RegExp.prototype.toJSON;
|
||||
RegExp.prototype.toJSON = RegExp.prototype.toString;
|
||||
@@ -81,6 +78,9 @@ function runTest(test, parseFunction) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
delete ast.tokens;
|
||||
if (ast.comments && !ast.comments.length) delete ast.comments;
|
||||
|
||||
if (!test.expect.code && !opts.throws && !process.env.CI) {
|
||||
test.expect.loc += "on";
|
||||
return save(test, ast);
|
||||
@@ -129,5 +129,15 @@ function misMatch(exp, act) {
|
||||
var mis = misMatch(exp[prop], act[prop]);
|
||||
if (mis) return addPath(mis, prop);
|
||||
}
|
||||
|
||||
for (var prop in act) {
|
||||
if (prop === "__clone") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(prop in exp) && act[prop] !== undefined) {
|
||||
return `Did not expect a property '${prop}'`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user