diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 4e7f9476..35ee0672 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -5814,12 +5814,16 @@ function isTestCall(n, parent) { if (isUnitTestSetUp(n)) { return isAngularTestWrapper(n.arguments[0]); } - } else if (n.arguments.length === 2) { + } else if (n.arguments.length === 2 || n.arguments.length === 3) { if ( ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name)) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0])) ) { + // it("name", () => { ... }, 2500) + if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) { + return false; + } return ( (isFunctionOrArrowExpression(n.arguments[1].type) && n.arguments[1].params.length <= 1) || diff --git a/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap b/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap index 37a676e9..267d6ea9 100644 --- a/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap +++ b/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap @@ -679,6 +679,19 @@ it.only.only("does something really long and complicated so I have to write a ve }); xskip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +// timeout + +it(\`handles + some + newlines + does something really long and complicated so I have to write a very long name for the test\`, () => { + console.log("hello!"); +}, 2500) + +it("does something quick", () => { + console.log("hello!") +}, 1000000000) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Shouldn't break @@ -800,6 +813,19 @@ xskip( () => {} ); +// timeout + +it(\`handles + some + newlines + does something really long and complicated so I have to write a very long name for the test\`, () => { + console.log("hello!"); +}, 2500); + +it("does something quick", () => { + console.log("hello!"); +}, 1000000000); + `; exports[`test_declarations.js - flow-verify 2`] = ` @@ -909,6 +935,19 @@ it.only.only("does something really long and complicated so I have to write a ve }); xskip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +// timeout + +it(\`handles + some + newlines + does something really long and complicated so I have to write a very long name for the test\`, () => { + console.log("hello!"); +}, 2500) + +it("does something quick", () => { + console.log("hello!") +}, 1000000000) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Shouldn't break @@ -1030,4 +1069,17 @@ xskip( () => {} ); +// timeout + +it(\`handles + some + newlines + does something really long and complicated so I have to write a very long name for the test\`, () => { + console.log("hello!"); +}, 2500); + +it("does something quick", () => { + console.log("hello!"); +}, 1000000000); + `; diff --git a/tests/test_declarations/test_declarations.js b/tests/test_declarations/test_declarations.js index f4978419..d90a4952 100644 --- a/tests/test_declarations/test_declarations.js +++ b/tests/test_declarations/test_declarations.js @@ -104,3 +104,16 @@ it.only.only("does something really long and complicated so I have to write a ve }); xskip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +// timeout + +it(`handles + some + newlines + does something really long and complicated so I have to write a very long name for the test`, () => { + console.log("hello!"); +}, 2500) + +it("does something quick", () => { + console.log("hello!") +}, 1000000000)