lundi 12 mars 2018

Jasmine refference error

I am using Jasmine, require js and chutzpah in my project. I want to test javascript file but I have a problem with that. I created a module with require.js and I want to test it. Inside a module, there is variable which is referenced to the global variable. Here is the HTML file which contains global variable (I receiving data from BackEnd model so I can't change it):

<script>
  var options = {
    key: '@Model.key',
    secondKey: '@Model.key2'
  }
</script>

and the module which I want to test is like:

define(['jquery'], function($) {
  'use strict';
  
  var keyOption = options.key;
  
})

After running tests it logs to the console Error: ReferenceError: Can't find variable: options; How can I do it correctly?

Aucun commentaire:

Enregistrer un commentaire