TestRunner.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * TestRunner.js
  3. *
  4. * This is for actually running the tests in the test register.
  5. *
  6. * @author tlwr [toby@toby.codes
  7. *
  8. * @copyright Crown Copyright 2017
  9. * @license Apache-2.0
  10. *
  11. */
  12. (function() {
  13. document.addEventListener("DOMContentLoaded", function() {
  14. TestRegister.runTests()
  15. .then(function(results) {
  16. results.forEach(function(testResult) {
  17. if (typeof window.callPhantom === "function") {
  18. window.callPhantom(
  19. "testResult",
  20. testResult
  21. );
  22. } else {
  23. var output = [
  24. "----------",
  25. testResult.test.name,
  26. testResult.status,
  27. testResult.output,
  28. ].join("<br>");
  29. document.body.innerHTML += "<div>" + output + "</div>";
  30. }
  31. });
  32. if (typeof window.callPhantom === "function") {
  33. window.callPhantom("exit");
  34. }
  35. });
  36. });
  37. })();