kotlin-examples
kotlin-examples copied to clipboard
All js-tests examples fail except for jest example
Hello, I am new to unit tests with kotlin-js and I am attempting to learn how to set it up using the karma example. However, it seems that there is something wrong with this example because even if I clone the project itself and run 'gradle test' it always produces the same error:
> Task :fusion-js:karmaRun FAILED
C:\Users\Aidan\IdeaProjects\fusion\fusion-js\node_modules\karma\node_modules\log4js\lib\layouts.js:69
) + util.format(...loggingEvent.data);
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\Aidan\IdeaProjects\fusion\fusion-js\node_modules\karma\node_modules\log4js\lib\log4js.js:27:17)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\Aidan\IdeaProjects\fusion\fusion-js\node_modules\karma\lib\logger.js:7:14)
at Module._compile (module.js:435:26)
It seems that the js spread operator is not supported by the javascript version, but I don't know what to do about it 🤷. Does somebody here know?
An update on this: it seems that running 'gradle test' in all the examples in the js-tests folder do not work, except for the jest example, which works as expected. I'm assuming they worked at one point but have become outdated somehow. Again, I am just trying to learn this myself so I am not sure what is wrong.
Have the same issue any updates?
Encountered the same issue.
Maybe the node version is an issue: https://github.com/karma-runner/karma/issues/3111#issuecomment-431572445
Any idea how to update the node version in com.craigburke.karma? From the craigburke sources I see that the used node version is the default in the plugin code...
Here is a good article that helps to make the JS tests work again: https://medium.com/@gz_k/effective-tool-chain-for-kotlin-js-testing-b243449e8a16
This solution has also a much faster build time than the karma gradle plugin.
If you use the amd format, here is an example how I got it running using requirejs: https://gitlab.com/czeidler/fejoa/tree/master/jsbindings
the node plugin version 1.2.0 does not seem to work anymore. And with version 1.3.1 I cannot use any dependencies in the tests. Anyone actually using that? Experiences with a good project setup?
Also it would be useful, if the examples would use dependencies, so that case is handled as well.