Skip to content

Instantly share code, notes, and snippets.

@lborgav
Forked from johnantoni/assert.css
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save lborgav/6405da6487552b11f437 to your computer and use it in GitHub Desktop.

Select an option

Save lborgav/6405da6487552b11f437 to your computer and use it in GitHub Desktop.
.pass:before {
content: 'PASS: ';
color: blue;
font-weight: bold;
}
.fail:before {
content: 'FAIL: ';
color: red;
font-weight: bold;
}
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);
};
<!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;
}
.fail:before {
content: 'FAIL: ';
color: red;
font-weight: bold;
}
</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);
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment