I’ve been writing unit tests for js-files in /site/lib/, and I’ve been trying to find some way to get code coverage running for the tests as well.
Jacoco seems to work fine for .java-files, but is there any way to get coverage for js-files ran through Nashorn?
Hi.
Yes, Jacoco is good for Java files but sadly it does not cover javascript files. Right now it’s not very easy to create a coverage tool for Nashorn. But in Java 9 it should be possible to create some sort of code-coverage tool that uses the same format as Jacoco or Emma.
Almost 7 years later, I’m having the exact same problem. Have things changed? Is it possible / easier to get code coverage for js/ts-tests of backend controllers?
1 Like
Yes, you can use jest.
I’ve used it in a bunch of projects now.
You’ll have to mock all the java code though. mock-xp can help with that.
Here’s some tests:
Mock-XP is still under Playground.
The coverage results can be made available here via github actions: