kotlin-examples icon indicating copy to clipboard operation
kotlin-examples copied to clipboard

All js-tests examples fail except for jest example

Open gnawinganimal opened this issue 7 years ago • 6 comments

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?

gnawinganimal avatar Aug 25 '18 22:08 gnawinganimal

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.

gnawinganimal avatar Aug 27 '18 06:08 gnawinganimal

Have the same issue any updates?

czeidler avatar Sep 27 '18 04:09 czeidler

Encountered the same issue.

kunalrdeshmukh avatar Oct 08 '18 20:10 kunalrdeshmukh

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...

czeidler avatar Oct 20 '18 19:10 czeidler

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

czeidler avatar Jan 02 '19 08:01 czeidler

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.

thigg avatar Jul 31 '19 10:07 thigg