I have a problem to run my tests with method names...
# javascript
j
I have a problem to run my tests with method names with spaces inside backticks. I get the following error from gradle:
Copy code
e: $PATH: Name contains illegal chars that can't appear in JavaScript identifier
:js:compileTestKotlin2Js FAILED
From the style guide: https://kotlinlang.org/docs/reference/coding-conventions.html#names-for-test-methods
Copy code
In tests (and only in tests), it's acceptable to use method names with spaces enclosed in backticks. (Note that such method names are currently not supported by the Android runtime.) Underscores in method names are also allowed in test code.
It only mentions that this is not working in Android so I assume it should work in JS. Am I doing something wrong or are they not supported at the moment? Using Kotlin 1.2.20
a
It is not supported at the moment: https://youtrack.jetbrains.com/issue/KT-18771
j
Ah that is unfortunate.. Thanks!
a
"You can write whatever you want in the backticks" is a common misconception. I was surprised as well. =(
s
Interesting that this still persists. Has it been decided that this is not something that would be improved upon? Too many limitations from all the potential targets? It’s just a bit unfortunate not being able to name our unit tests as we usually would, with backticks in commonTest. Is there some sort of official workaround/trick aside from just not using backticks and spaces but going with an underscore instead?
e
@JsName
?
s
Yeah that seems to work actually! Didn’t know about it. A bit annoying to have to write the same thing twice then once with spaces and once with underscores or something similar. I guess some sort of magic find and replace regex can make this a simpler thing.