jsApiReporter was initially added as part of the pre-1.0 Ruby based browser runner. It looks like it was designed to resolve a race condition betweeen jasmine-core's startup in the browser and the Ruby runner's startup. Modern runners handle that either by buffering messages in a custom reporter (e.g. jasmine-browser-runner's BatchReporter) or by calling env.execute() after a communication channel has been set up (e.g. the old Jasmine ruby gem). In any other context, a custom reporter is easier to use than jsApiReporter because it doesn't require polling. Adding jsApiReporter to the env imposes small but measurable penalties in time and space, both of which are proportional to the size of the test suite. Other than jasmine-py and Testdouble's jasmine-rails gem, neither of which ever supported jasmine-core 4 or later, I can find scant evidence of interest and no evidence of usage after about 2012.
80 lines
3.0 KiB
JavaScript
80 lines
3.0 KiB
JavaScript
/*
|
|
Copyright (c) 2008-2019 Pivotal Labs
|
|
Copyright (c) 2008-2025 The Jasmine developers
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of this software and associated documentation files (the
|
|
"Software"), to deal in the Software without restriction, including
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
This file finishes 'booting' Jasmine, performing all of the necessary
|
|
initialization before executing the loaded environment and all of a project's
|
|
specs. This file should be loaded after `boot0.js` but before any project
|
|
source files or spec files are loaded. Thus this file can also be used to
|
|
customize Jasmine for a project.
|
|
|
|
If a project is using Jasmine via the standalone distribution, this file can
|
|
be customized directly. If you only wish to configure the Jasmine env, you
|
|
can load another file that calls `jasmine.getEnv().configure({...})`
|
|
after `boot0.js` is loaded and before this file is loaded.
|
|
*/
|
|
|
|
(function() {
|
|
const env = jasmine.getEnv();
|
|
const urls = new jasmine.HtmlReporterV2Urls();
|
|
|
|
/**
|
|
* ## Reporters
|
|
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
|
*/
|
|
const htmlReporter = new jasmine.HtmlReporterV2({
|
|
env,
|
|
urls,
|
|
getContainer() {
|
|
return document.body;
|
|
}
|
|
});
|
|
|
|
env.addReporter(htmlReporter);
|
|
/**
|
|
* Configures Jasmine based on the current set of query parameters. This
|
|
* supports all parameters set by the HTML reporter as well as
|
|
* spec=partialPath, which filters out specs whose paths don't contain the
|
|
* parameter.
|
|
*/
|
|
env.configure(urls.configFromCurrentUrl());
|
|
|
|
/**
|
|
* ## Execution
|
|
*
|
|
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
|
*/
|
|
const currentWindowOnload = window.onload;
|
|
|
|
window.onload = function() {
|
|
if (currentWindowOnload) {
|
|
currentWindowOnload();
|
|
}
|
|
htmlReporter.initialize();
|
|
env.execute();
|
|
};
|
|
})();
|