Add support for timeouts passed as integers to test functions (#5085)
* Add support for timeouts passed as integers to test functions * ;master
parent
f7a6625d84
commit
59720392c3
|
@ -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) ||
|
||||
|
|
|
@ -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);
|
||||
|
||||
`;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue