Main js file that starts everything:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>InterfaceTest</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css">
<script type="text/javascript" src="https://rawgit.com/angular/bower-angular-mocks/master/angular-mocks.js"></script>
<script src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://rawgit.com/danielfm/jshamcrest/master/src/jshamcrest.js"></script>
<script type="text/javascript" src="https://rawgit.com/cleishm/jsmockito/master/src/jsmockito.js"></script>
<script src="Interface.js" ></script>
<script src="InterfaceTest.js" ></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
InterfaceTest:
QUnit.test("mockitoTest", function(assert) {
var mockedObject = mock(Array);
when(mockedObject).get(1).thenReturn("hello world");
alert(mockedObject.get(1));
});
I need to use Jquery, Hamcrest, and JsMockito to make a bunch of unit tests for Interface (doesn't matter what's in it).
The error I get:
Died on test #1 at file:///C:/Internship/JavaScript/Qunit/InterfaceTest.js:1:7: mock is not defined@
Source:
ReferenceError: mock is not defined
at Object.<anonymous> (file:///C:/Internship/JavaScript/Qunit/InterfaceTest.js:2:21)
I'm sure it's something obvious, but I've included Mockito as a dependency so I don't know why it says mock is not defined. My assumption is that
<script `type="text/javascript" src="https://rawgit.com/cleishm/jsmockito/master/src/jsmockito.js"></script>
must be wrong.
(i saw on another stackoverflow post that if you post the github link on https://rawgit.com/ then you can include it as the src, so that's where those links are coming from)
When I ran your code I saw the error Can not set mock of undefined
and pointed to the angular-mocks.js
file.
The file angular-mocks.js
is expecting angular, but you do not load angular.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.