UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

108 lines (81 loc) 3.65 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Class(&#39;Siesta.Result.SubTest&#39;, { isa : Siesta.Result, has : { // reference to a test it belongs to // SubTests result instances will be set as `results` for sub tests instances test : null }, methods : { isWorking : function () { return !this.test.isFinished() }, toJSON : function () { var test = this.test // a flag that test instance does not belongs to the current context // this only happens during self-testing // if this is the case, in IE, calling any method from the test context will throw exception // &quot;can&#39;t execute script from freed context&quot;, so we avoid calling any methods on the test in such case // accessing properties is ok though var isCrossContext = !(test instanceof Object) var report = { id : this.id, parentId : test.parent ? test.parent.getResults().id : null, type : this.meta.name, name : test.name, startDate : test.startDate, endDate : test.endDate || (new Date() - 0), passed : isCrossContext ? null : test.isPassed() } // top level test if (!test.parent) { report.automationElementId = test.automationElementId report.url = test.url report.jUnitClass = test.getJUnitClass() report.groups = test.groups } if (test.specType) report.bddSpecType = test.specType if (test.isTodo) report.isTodo = true var isFailed = false var assertions = [] Joose.A.each(this.children, function (result) { if ((result instanceof Siesta.Result.Assertion) || (result instanceof Siesta.Result.Diagnostic) || (result instanceof Siesta.Result.SubTest)) { var assertion = result.toJSON() if (!assertion.passed &amp;&amp; !assertion.isTodo) isFailed = true assertions.push(assertion) } }) report.assertions = assertions // see a comment above if (isCrossContext) { report.passed = !(isFailed || test.failed || !test.endDate) } return report } } }) </pre> </body> </html>