Run tests in Kotlin/JS
You can tune how tests are executed in Kotlin/JS by adjusting the settings available in the
testTask block in the Gradle build script. For example, using the Karma test runner together with a headless instance of Chrome and an instance of Firefox looks like this:
For a detailed description of the available functionality, check out the Kotlin/JS reference on configuring the test task.
Please note that by default, no browsers are bundled with the plugin. This means that you'll have to ensure they're available on the target system.
To check that tests are executed properly, add a file
src/test/kotlin/AppTest.kt and fill it with this content:
To run the tests in the browser, execute the
browserTest task via IntelliJ IDEA, or use the gutter icons to execute all or individual tests:
Alternatively, if you want to run the tests via the command line, use the Gradle wrapper:
After running the tests from IntelliJ IDEA, the Run tool window will show the test results. You can click failed tests to see their stack trace, and navigate to the corresponding test implementation via a double-click.
After each test run, regardless of how you executed the test, you can find a properly formatted test report from Gradle in
build/reports/tests/browserTest/index.html. Open this file in a browser to see another overview of the test results:
If you are using the set of example tests shown in the snippet above, one test passes, and one test breaks, which gives the resulting total of 50% successful tests. To get more information about individual test cases, you can navigate via the provided hyperlinks: