diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Testing.qll b/javascript/ql/lib/semmle/javascript/frameworks/Testing.qll index fb2d85523d4..63b3234ea6c 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Testing.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Testing.qll @@ -39,12 +39,14 @@ class BDDTest extends Test, @call_expr { } /** - * Gets the test file for `f` with stem extension `stemExt`. + * Gets the test file for `f` with stem extension `stemExt`, where `stemExt` is "test" or "spec". * That is, a file named file named `..` in the * same directory as `f` which is named `.`. */ -bindingset[stemExt] +pragma[noinline] File getTestFile(File f, string stemExt) { + stemExt = ["test", "spec"] and + result.getBaseName().regexpMatch(".*\\.(test|spec)\\..*") and result = f.getParentContainer().getFile(f.getStem() + "." + stemExt + "." + f.getExtension()) }