Skip to content

Commit 930a59d

Browse files
committed
Improve spec test harness for debugging
* Print diagnostic message for invalid source map tests with the error messages in the exception to make it easier to tell if maps are invalid for the right reason * Use `todo` instead of `skip` to print out the failure messages for known failures so that they can be fixed later
1 parent 6a60a6a commit 930a59d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/spec-tests.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1010
const specResourcesBaseDir = path.resolve(__dirname, "../../source-map-tests/resources");
1111

1212
// These tests are known failures that aren't easily fixed at the moment.
13-
const skippedTests = [
13+
const knownFailures = [
1414
// Source maps library does not consider this a parse error.
1515
"invalidMappingSegmentWithZeroFields",
1616
// Source maps library ignores the sign bit in the size limit.
@@ -24,9 +24,8 @@ const skippedTests = [
2424
test.describe("runSourceMapSpecTests", () => {
2525
sourceMapSpecTests.tests.forEach((testCase) => {
2626
test(`The source map spec test case "${testCase.name}" has ${testCase.sourceMapIsValid ? "a valid" : "an invalid"} source map`, async (t) => {
27-
if (skippedTests.includes(testCase.name)) {
28-
t.skip();
29-
return;
27+
if (knownFailures.includes(testCase.name)) {
28+
t.todo("This test has a known failure and doesn't fail the test suite");
3029
}
3130
const result = await validateSourceMap([
3231
"--sourceMap",
@@ -38,8 +37,11 @@ test.describe("runSourceMapSpecTests", () => {
3837
]);
3938
if (testCase.sourceMapIsValid)
4039
assert.deepEqual(result, { isValid: true }, "expected source map to be valid");
41-
else
40+
else {
4241
assert.equal(result.isValid, false, "expected source map to be invalid");
42+
if (!result.isValid && result.errors[0])
43+
t.diagnostic(result.errors[0].message);
44+
}
4345
});
4446
});
4547
});

0 commit comments

Comments
 (0)