javascript - Why is index.html being treated as JSON? Unexpected token < at position 0 -
i trying use qunit make unit tests html. error i'm getting uncaught syntaxerror: unexpected token < in json @ position 0
. it's pointing "<" in <!doctype html>
isn't json, thinks is, i'm not sure why.
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>pinpoint test</title> <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css"> <script type="text/javascript" src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script> <script type="text/javascript" src="lib/jquery-3.0.0.min.js"></script> <script type="text/javascript" src="jshamcrest.js"></script> <script type="text/javascript" src="core.js"></script> <script type="text/javascript" src="integration.js"></script> <script type="text/javascript" src="jsmockito-1.0.4.js"></script> <script type="text/javascript" src="lib/handlebars-v4.0.5.js"></script> <script type="text/javascript" src="bootstrap.min.js"></script> <script src="pinpoint.js"></script> <script src="pinpointtest.js"></script> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"> //a lot more html </body> </html
it says source: @ window.onerror (https://code.jquery.com/qunit/qunit-2.0.0.js:322:11)
qunit-2.0.0.js:
// cover uncaught exceptions // returning true suppress default browser handler, // returning false let run. window.onerror = function( error, filepath, linernr ) { var ret = false; if ( onerrorfnprev ) { ret = onerrorfnprev( error, filepath, linernr ); } // treat return value window.onerror does, // our handling if not suppressed. if ( ret !== true ) { if ( qunit.config.current ) { if ( qunit.config.current.ignoreglobalerrors ) { return true; } qunit.pushfailure( error, filepath + ":" + linernr ); } else { //322 qunit.test( "global failure", extend( function() { qunit.pushfailure( error, filepath + ":" + linernr ); }, { validtest: true } ) ); } return false; } return ret; };
my guess missing >
@ end of html file typo in example? think might need put these <script>
tags @ end of <body>
instead of in <head>
... qunit wants <div id="qunit"></div>
tag put ui in, , is, tests trying run before html ever loads. give try, if doesn't work, can simplify test simple assert.equall(1, 1)
see if works? update question actual tests if want @ them.
Comments
Post a Comment