how to solve jasmine error "Error during loading: Script error." when jquery used?

347 Views Asked by At

I test cordova project with jasmine and I add jquery and jasmine-jquery to jasmine test but jasmine show below code .

ReferenceError: selectLevel() is not defined

and Jasmine not worked and return Error during loading: Script error. when my app.js is

(function($) {
function selectLevel() {
      level = 1;
  }
})(jQuery);

but work when (function($) { removed

JasmineHTML FIle

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Jasmine Spec Runner v3.5.0</title>

  <link rel="shortcut icon" type="image/png" href="lib/jasmine-3.5.0/jasmine_favicon.png">
  <link rel="stylesheet" href="lib/jasmine-3.5.0/jasmine.css">

  <script src="lib/jasmine-3.5.0/jasmine.js"></script>
  <script src="lib/jasmine-3.5.0/jasmine-html.js"></script>
  <script type="text/javascript" src="lib/jasmine-3.5.0/jasmine-jquery.js"></script>
  <script type="text/javascript" src="lib/jasmine-3.5.0/jquery.js"></script>
  <script src="lib/jasmine-3.5.0/boot.js"></script>

  <!-- include source files here... -->
  <script type="text/javascript" src="app.js"></script>

  <!-- include spec files here... -->

  <script src="spec/PlayerSpec.js"></script>

</head>

<body>
</body>
</html>

In this case, how do I solve this?

0

There are 0 best solutions below