Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: More detailed assert message for rule-tester (#9769)
* Update: More detailed assert message for rule-tester * [squash]add try/finally block * [squash]append message instead of overwriting it * [squash]add parentheses surrounding error message
- Loading branch information
1 parent
9fcfabf
commit c64195f
Showing
2 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @fileoverview Tests for RuleTester without any test runner | ||
* @author Weijia Wang <starkwang@126.com> | ||
*/ | ||
"use strict"; | ||
|
||
/* global describe, it */ | ||
/* eslint-disable no-global-assign*/ | ||
const assert = require("assert"), | ||
RuleTester = require("../../../lib/testers/rule-tester"); | ||
const tmpIt = it; | ||
const tmpDescribe = describe; | ||
|
||
it = null; | ||
describe = null; | ||
|
||
try { | ||
const ruleTester = new RuleTester(); | ||
|
||
assert.throws(() => { | ||
ruleTester.run("no-var", require("../../fixtures/testers/rule-tester/no-var"), { | ||
valid: [ | ||
"bar = baz;" | ||
], | ||
invalid: [ | ||
{ code: "var foo = bar;", output: "invalid output", errors: 1 } | ||
] | ||
}); | ||
}, /Output is incorrect\. \(' foo = bar;' == 'invalid output'\)$/); | ||
} catch (e) { | ||
throw e; | ||
} finally { | ||
it = tmpIt; | ||
describe = tmpDescribe; | ||
} |