@@ -35,12 +35,15 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
3535 }
3636
3737 private fun getTestName (element : PsiElement ? ): String? {
38- if (element == null || element !is JSCallExpression ) {
38+ if (element == null || element.parent == null ) {
3939 return null
4040 }
4141
42- val jsCallExpression: JSCallExpression = element
42+ if (element !is JSCallExpression ) {
43+ return getTestName(element.parent)
44+ }
4345
46+ val jsCallExpression: JSCallExpression = element
4447 if (jsCallExpression.isTest()) {
4548 val arguments: Array <JSExpression > = jsCallExpression.arguments
4649 if (arguments.isNotEmpty()) {
@@ -74,6 +77,8 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
7477 }
7578 val filePath = currentFile.path
7679 val fileName = Paths .get(filePath).fileName.toString()
80+ val basePath = project.basePath
81+ val relPath = if (basePath == null ) fileName else currentFile.path.substring(basePath.length + 1 )
7782 val node: NodeJsRunConfiguration ? =
7883 NodeJsRunConfiguration .getDefaultRunConfiguration(project)?.clone() as NodeJsRunConfiguration ?
7984 if (node == null ) {
@@ -85,14 +90,14 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
8590 writeError(" Factory not found" )
8691 return
8792 }
88- node.workingDirectory = project. basePath
93+ node.workingDirectory = basePath
8994 node.inputPath = " node_modules/ava/cli.js"
9095 if (testName != null ) {
9196 node.name = " ava $fileName $testName "
92- node.applicationParameters = " -m \" $testName \" -v $fileName "
97+ node.applicationParameters = " -m \" $testName \" -v $relPath "
9398 } else {
9499 node.name = " ava $fileName "
95- node.applicationParameters = " -v $fileName "
100+ node.applicationParameters = " -v $relPath "
96101 }
97102 val runManager = RunManager .getInstance(project)
98103 val configuration: RunnerAndConfigurationSettings = runManager.createConfiguration(node, factory)
0 commit comments