Jasmine HtmlReporter calls himself turns out to be undefined

I am testing the application of Magical Magic. The test page consists of the following scenarios:

  • Jasmine: <script src="../testing/lib/jasmine-1.3.1/jasmine.js"></script>
  • Jasmine HTML Reporter: <script src="../testing/lib/jasmine-1.3.1/jasmine-html.js"></script>
  • My specification: <script src="js/app.spec.js"></script>
  • Setup: window.onload code copied exactly from gismub Jasmine page

The odd part, I keep getting this error:

 Uncaught TypeError: Cannot read property 'SuiteView' of undefined 

I looked at the stack trace. jasmine.HtmlReporter prepares to display the final test result after all tests have completed. It calls jasmine.HtmlReporterHelpers.appendToSummary , where jasmine.HtmlReporter is undefined , as shown in the screenshot below.

The object method cannot find itself. How can this happen?

+4
source share
1 answer

Uncaught TypeError: Unable to read "SuiteView" property undefined

SuiteView is a property of the currently executable package, which is missing in this case. Jasmine has the following life cycle:

 var jasmineEnv = jasmine.getEnv (); //Initialize Environment jasmineEnv.updateInterval = 1000; var htmlReporter = new jasmine.HtmlReporter (); //Initialize Reporter jasmineEnv.addReporter (htmlReporter); //Add Reporter jasmineEnv.execute (); //Start Suite 

Here is the full script:

 <script> function load() { var description = location.hash.match(/".+"/).toString().replace(/"/g,""); var spec = location.hash.match(/function.+}/).toString(); var result = Function("return " + spec)(); var len = jasmine.getEnv().topSuite().children.length; var test; var suite; var suite_name; var reporter_args; var reporter_methods; var i; test = jasmine.getEnv().it(description, result); suite = jasmine.getEnv().topSuite().children[len]; reporter_args = jasmine.HtmlReporter.toString().match(/options\.[a-zA-Z]+/g); reporter_methods = jasmine.HtmlReporter.toString().match(/this\.[a-zA-Z]+/g) var suite_name = suite.fullname; for(i = 0; i < len; i++) { jasmine.getEnv().topSuite().children.shift(); } jasmine.getEnv().execute(suite_name); } </script> 

References

0
source

All Articles