This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Easy JavaScript Testing></title> | |
<style> | |
.pass:before { | |
content: 'PASS: '; | |
color: blue; | |
font-weight: bold; | |
font-family: monospace | |
} | |
.fail:before { | |
content: 'FAIL: '; | |
color: red; | |
font-weight: bold; | |
font-family: monospace | |
} | |
</style> | |
</head> | |
<body> | |
<ul id="output"></ul> | |
<script> | |
var output = document.getElementById('output'); | |
function assert( outcome, description ) { | |
var li = document.createElement('li'); | |
li.className = outcome ? 'pass' : 'fail'; | |
li.appendChild(document.createTextNode(description)); | |
output.appendChild(li); | |
}; | |
function add(num1, num2) { | |
return num1 + num2; | |
} | |
assert (add(5, 20) === 24, '5 + 20 = 24') | |
assert (add(5, 20) === 25, '5 + 20 = 24') | |
</script> | |
</body> | |
<html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As seen here Quick and Easy JavaScript testing with assert with one minor change