Skip to content

Instantly share code, notes, and snippets.

@crongro
Last active September 11, 2015 04:55
Show Gist options
  • Save crongro/53ed6850ffd81137fa5c to your computer and use it in GitHub Desktop.
Save crongro/53ed6850ffd81137fa5c to your computer and use it in GitHub Desktop.
In System.js, react module unit test using Qunit
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>qunit test</title>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css"/>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="wrapper">
</div>
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../jspm_packages/system.js"></script>
<script src="../config.js"></script>
//isn't bundle.
<script src="simpleWithUI.test.js"></script>
</body>
</html>
System.import('app/js/pages/simpleWithUI').then(function(m){
//then
m.default.increaseOrderCount();
//due to React view rendering, async is needed.
QUnit.test( "hello test", function( assert ) {
assert.ok( "1" == "1", "Passed!" );
var done = assert.async();
setTimeout(function() {
var data = document.querySelector(".itemDetail > div:nth-child(2) > span:nth-child(2) > span:first-child").innerText;
assert.ok( data == "1", "Passed!" );
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment