Search code examples
intern

Trouble making a request to an API after the last 'session/end'


I'm currently working on a custom reporter that sends test results to Sauce Labs. The current version of the reporter can be found here.

The problem with it is that it doesn't send the data after the last session. For instance, if I have 2 browsers to test on, it will only send the results for the first browser tested, stopping before sending the second one.

The request is made at the 'session/end' topic from the ones available. From what I can tell the entire thing stops before the last request is made.

I made a more isolated custom reporter to show off the problem using setTimeout() instead of a request. See it here.

Thanks!


Solution

  • The Intern process exits explicitly immediately after all sessions are complete (after /runner/end is published), so an asynchronous operation like that is unlikely to have enough time to complete successfully.

    Intern 1.2 will contain an improvement so it will wait until any outstanding operations complete, and this will work as you expect it to.