Search code examples
javascriptintern

Display the results of intern-runner functional tests on a browser


I want to display the results of intern-runner on a browser. All the reporters of intern-runner are displaying the results on the console. Do I need to write a custom reporter for this or is there any config tweak that I should do. If I need to write a custom reporter, do I need to output the results to a JSON and then open a html file at the end of the reporter which consumes the JSON produced by the custom reporter. Could someone please let me know the best practice.


Solution

  • Intern-runner doesn't include any sort of browser result display by default because it doesn't fit the test model very well. Runner can open many browsers, and browsers may be on remote machines you're not looking at; having to jump between a bunch of browsers to see your test results would be a pain.

    Rendering results to something other than, or in addition to, the console is a very reasonable thing to do. Intern provides several reporters that already do this: junit outputs a JUnit XML file, lcovhtml writes an HTML code coverage report, and teamcity outputs a file in TeamCity's report syntax.

    In your case, it'd be simplest to write results directly to an HTML file that could then be opened in a browser. Intern doesn't include a reporter that does this (the built-in html reporter requires a browser), but the junit reporter provides a good example of how to write a simple reporter than generates XML markup.