Skip AST_COMPARE test if code didn't change (#7800)

* Skip `AST_COMPARE` test if code didn't change

* use basename

* Use `test.skip`

* Code style
This commit is contained in:
fisker Cheung authored and GitHub committed 2020-04-07 14:38:25 +03:00
1 parent ccaaad007d
commit 0c1b737cde
1 file changed
+9 -14
+9 -14
View File
@@ -178,21 +178,16 @@ global.run_spec = (dirname, parsers, options) => {
}
if (AST_COMPARE) {
test(`${basename} parse`, () => {
const parseOptions = { ...mainOptions };
delete parseOptions.cursorOffset;
const formatted = output.replace(CURSOR_PLACEHOLDER, "");
const originalAst = parse(input, parseOptions);
let formattedAst;
expect(() => {
formattedAst = parse(
output.replace(CURSOR_PLACEHOLDER, ""),
parseOptions
);
}).not.toThrow();
expect(originalAst).toEqual(formattedAst);
});
if (formatted !== input) {
test(`${basename} parse`, () => {
const { cursorOffset, ...parseOptions } = mainOptions;
const originalAst = parse(input, parseOptions);
const formattedAst = parse(formatted, parseOptions);
expect(originalAst).toEqual(formattedAst);
});
}
}
}
};