* @name jsApiReporter * @classdesc Reporter added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object. * @class * @hideconstructor
(options)
| 2031 | * @hideconstructor |
| 2032 | */ |
| 2033 | function JsApiReporter(options) { |
| 2034 | const timer = options.timer || new j$.Timer(); |
| 2035 | let status = 'loaded'; |
| 2036 | |
| 2037 | this.started = false; |
| 2038 | this.finished = false; |
| 2039 | this.runDetails = {}; |
| 2040 | |
| 2041 | this.jasmineStarted = function() { |
| 2042 | this.started = true; |
| 2043 | status = 'started'; |
| 2044 | timer.start(); |
| 2045 | }; |
| 2046 | |
| 2047 | let executionTime; |
| 2048 | |
| 2049 | this.jasmineDone = function(runDetails) { |
| 2050 | this.finished = true; |
| 2051 | this.runDetails = runDetails; |
| 2052 | executionTime = timer.elapsed(); |
| 2053 | status = 'done'; |
| 2054 | }; |
| 2055 | |
| 2056 | /** |
| 2057 | * Get the current status for the Jasmine environment. |
| 2058 | * @name jsApiReporter#status |
| 2059 | * @since 2.0.0 |
| 2060 | * @function |
| 2061 | * @return {String} - One of `loaded`, `started`, or `done` |
| 2062 | */ |
| 2063 | this.status = function() { |
| 2064 | return status; |
| 2065 | }; |
| 2066 | |
| 2067 | const suites = [], |
| 2068 | suites_hash = {}; |
| 2069 | |
| 2070 | this.suiteStarted = function(result) { |
| 2071 | suites_hash[result.id] = result; |
| 2072 | }; |
| 2073 | |
| 2074 | this.suiteDone = function(result) { |
| 2075 | storeSuite(result); |
| 2076 | }; |
| 2077 | |
| 2078 | /** |
| 2079 | * Get the results for a set of suites. |
| 2080 | * |
| 2081 | * Retrievable in slices for easier serialization. |
| 2082 | * @name jsApiReporter#suiteResults |
| 2083 | * @since 2.1.0 |
| 2084 | * @function |
| 2085 | * @param {Number} index - The position in the suites list to start from. |
| 2086 | * @param {Number} length - Maximum number of suite results to return. |
| 2087 | * @return {SuiteResult[]} |
| 2088 | */ |
| 2089 | this.suiteResults = function(index, length) { |
| 2090 | return JSON.stringify(suites.slice(index, index + length)); |
nothing calls this directly
no test coverage detected