Skip to content

Commit 0efbfd7

Browse files
committed
driveby: better formatting of errors
1 parent d243e36 commit 0efbfd7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/spectral/ipa/__tests__/__helpers__/testRule.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, expect, it } from '@jest/globals';
44
import { Spectral, Document } from '@stoplight/spectral-core';
55
import { httpAndFileResolver } from '@stoplight/spectral-ref-resolver';
66
import { bundleAndLoadRuleset } from '@stoplight/spectral-ruleset-bundler/with-loader';
7+
import { fail } from 'node:assert';
78

89
export default (ruleName, tests) => {
910
describe(`Rule ${ruleName}`, () => {
@@ -13,6 +14,12 @@ export default (ruleName, tests) => {
1314
const doc = testCase.document instanceof Document ? testCase.document : JSON.stringify(testCase.document);
1415
const errors = await s.run(doc);
1516

17+
if (testCase.errors.length !== errors.length) {
18+
fail(`Expected errors do not match actual errors
19+
(${testCase.errors.length} !== ${errors.length})
20+
Expected errors: ${JSON.stringify(testCase.errors, undefined, 2)}
21+
Actual errors: ${JSON.stringify(errors, undefined, 2)}`);
22+
}
1623
expect(errors.length).toEqual(testCase.errors.length);
1724

1825
errors.forEach((error, index) => {

0 commit comments

Comments
 (0)