I have a simple app that I am trying to write a unit test for. I want to unit test the help button in the sample code below to make sure the loading status becomes an empty string. However, I cannot figure out how to get a fake DOM working. I have tried jsdom, jsdomifiy, jsdom-global, etc. I always end up with appStatus being undefined, then I can't set the innerHTML property. I am trying to use karma and mocha, but if there is a better way please let me know. I don't really have a package.json to share because I have tried so many things.
var appStatus = document.getElementById('appStatus');
appStatus.innerHTML = 'Loading your app...';
function help() {
console.log('help clicked');
appStatus.innerHTML = '';
}
<!DOCTYPE html>
<html>
<head>
<title>App</title>
</head>
<body>
<span id="appStatus"></span>
<button onclick="help()">Help</button>
</body>
</html>