Skip to content

Commit c2e158c

Browse files
jamestalmagejfmengels
authored andcommitted
Allow macro use with test-title rule. (#112)
Currently, the `test-title` rule will freak out if you use macros with more than one argument. Unfotuneately, this simple fix is going to let some errors slip through. Specifically, if you don't attach a `title` function to your macro, and don't supply a string title, we probably should error, but that requires some rather involved type analysis to see if they ever did attach a title method to the macro.
1 parent ec4cedc commit c2e158c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

rules/test-title.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function (context) {
1515
testCount++;
1616

1717
var requiredLength = ava.hasTestModifier('todo') ? 1 : 2;
18-
var hasNoTitle = node.arguments.length !== requiredLength;
18+
var hasNoTitle = node.arguments.length < requiredLength;
1919
var isOverThreshold = !ifMultiple || testCount > 1;
2020

2121
if (hasNoTitle && isOverThreshold) {

test/test-title.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ test(() => {
6464
code: header + 'notTest(t => { t.pass(); t.end(); });',
6565
options: ['always']
6666
},
67+
{
68+
code: header + 'test(macroFn, arg1, arg2);',
69+
options: ['always']
70+
},
6771
// shouldn't be triggered since it's not a test file
6872
{
6973
code: 'test(t => {});',

0 commit comments

Comments
 (0)