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. * @copyright Crown Copyright 2017
  8. * @license Apache-2.0
  9. */
  10. document.addEventListener("DOMContentLoaded", function() {
  11. TestRegister.runTests()
  12. .then(function(results) {
  13. results.forEach(function(testResult) {
  14. if (typeof window.callPhantom === "function") {
  15. // If we're running this in PhantomJS
  16. window.callPhantom(
  17. "testResult",
  18. testResult
  19. );
  20. } else {
  21. // If we're just viewing this in a normal browser
  22. var output = [
  23. "----------",
  24. testResult.test.name,
  25. testResult.status,
  26. testResult.output,
  27. ].join("<br>");
  28. document.querySelector("main").innerHTML += output;
  29. }
  30. });
  31. if (typeof window.callPhantom === "function") {
  32. window.callPhantom("exit");
  33. }
  34. });
  35. });