Somehow I managed that running the `jsNodeTest` ta...
# javascript
v
Somehow I managed that running the
jsNodeTest
task does not run any tests anymore but complains that no tests were run and in future Gradle version this will fail. 😕 Any idea how I can find out why no test are running?
a
@Ilya Goncharov [JB] did we change something in the tests infrastructure?
v
It's not by a change by you. It worked yesterday. And I even used "Local HIstory" to revert to a state where I for sure know the tests run and failed, I checked that in the Gradle daemon logs. (Unless the local history did not revert some relevant part because it is due to some ignored file or similar)
But I'd also like to find out why it is not working to know what the reason is and how to fix it, or whether there is maybe a bug.
What the ...
Now they run again
That does not make any sense at all
Argh, now I reverted the revert and it again does not execute any tasks
i
Hi, it is a specific behaviour which related with how we run tests in Js and native. Actually the task is marked as up to date in your case, thats why Gradle does not run tests at all. To make it run you can run task "cleanAllTests"
v
Do you mean the Gradle task itself? That is not up to date, I ensured that. I even edit a test file and it doesn't change behavior. I can try that task in a bit, on mobile right now
i
Hm, in that case it may be something else, but let’s try first the task
v
No change
Now it suddenly started to work again, but I don't know why, this is really driving me nuts and I have this for a few days already, I just thought I had hallucinations as it only happened occasionally. Just now that it was very stubborn I'm sure it was not me.
i
Do you have your project as open or private? Can I see its build script, if it has some specific blocks?
i
I can see that in compiled file there is no test block, so it is somehow related with compiler process (either with compiler plugin or compiler itself). As I see
kotest
is used, maybe it is related with it and
kotest
does not generate running block in
js
file @Artem Kobzar
v
How do you see that? Does it also fail for you right now? For me right now it is working in that state.
i
For me it does not work indeed 🙂 And I failed with moving it to working state I took a look on
build/js/packages/github-actions-typing-test/kotlin/github-actions-typing-test.mjs
Usually (when
kotlin-test
is used) in the end there is block which just run some functions (test functions). But in your sample I can see only JS declarations without any execution in JS sources
v
Can you send that file?
i
It is compiled file. And there is no any executed blocks, as I can see
I am not sure maybe kotest works somehow else, but anyway in one of generated JS files there should be at least one execution block (otherwise what should be executed during a test)
v
left is yours, right is mine currently:
i
So now you have execution block (
main
function) And probably when it does not work for you, you have something similar to my file
v
Yes, you are right. Thanks to IJ local history I can see exactly that. Right before I said
Vampire [17:32 Uhr]
What the ...
Vampire [17:32 Uhr]
Now they run again
I see that the main stuff was added. I did (yet another) change in the test code so it caused a recompilation and added it. While some minutes before the initial message in this thread there was a change where the main stuff was removed.
So yes, this definitely seems to be the problem. Now the question is, who should add it and does not and why.
i
As I understand it should be added by kotest, but @Artem Kobzar is better person to investigate it
v
Hm, now I did
gradle compileTestKotlinJs --rerun compileTestDevelopmentExecutableKotlinJs --rerun
(as I was not sure which of the tasks does what) and now also miss the main stuff. Definitely something during compilation
In any way, many thanks for the help so far. I wouldn't probably have needed quite some time to come that far alone. 🙂
👍 1
Just making sure it is recompiled is not enough. I changed a test name, the change got into the result, but the main stuff is still missing
Time to find out how I can debug a Kotlin Compiler Plugin I guess 😳
That method that creates the main method is called, but
Copy code
declarationParent.getDeclarations().get(0).getSymbol().toString()
evaluates to
Copy code
CLASS CLASS name:Ajv modality:FINAL visibility:public [external] superTypes:[kotlin.Any]
and the method is missing from the result. Would be interesting to see what it is when it works, if I were just able to get to a working state. 🙄
Ah, removed the Ajv class and the main method was there, but the expression did not work as declarations was empty 🤪
I created https://github.com/kotest/kotest/issues/4678, maybe the kotest folks find something quicker than me 😄
🙏 1
i
Thank you! I think it is better way, if they find something where Gradle plugin or compiler do something unexpected, they’ll report to us
v
Thanks again for your help to get to the bottom of it
Ah, the generated
main
method is added to the first file in the list of files which happens to be the
Ajv.kt
.
Ajv.kt
is annotated with
@file:JsModule("ajv")
. And this then seems to somehow swallow the
main
method. If I remove the
@file:JsModule("ajv")
annotation, the
main
method appears in the output. I guess in the cases where it worked, the first file happend to be not
Ajv.kt
or
jsonlint.kt
and then it worked. If my assumption is right, the question is, whether it should work like kotest does it, or whether kotest should add the method to a different file like one where no such file annotation is present, or searching for one of the files that contains one of the specs.
I guess the latter
And merged 🙂