Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript dependency injection using RequireJS, Jasmine and testr
    primarykey
    data
    text
    <p>I've just looking for dependency injection in my unit test strategy using RequireJS and Jasmine. I really like the idea behind <a href="https://github.com/mattfysh/testr.js" rel="nofollow">testr</a> and I have tried to setup testr following the examples in github but I can't figure out what is wrong. I always get the error</p> <blockquote> <p>Error: module has not been loaded: <strong>today</strong></p> </blockquote> <p>when testr tries to load the module that is going to be tested.</p> <p>Here some context..</p> <p><strong>index.html</strong> ..</p> <pre><code>&lt;script data-main="config" src="../../assets/js/libs/require.js"&gt;&lt;/script&gt; &lt;script src="vendor/testr.js"&gt;&lt;/script&gt; </code></pre> <p><strong>config.js</strong> ..</p> <pre><code>require.config({ // Initialize specs. deps:["main"], ... ... }); </code></pre> <p><strong>main.js</strong> ..</p> <pre><code>require([ // Load the example spec, replace this and add your own spec "spec/today" ], function() { var jasmineEnv = jasmine.getEnv(); jasmineEnv.execute(); }); </code></pre> <p><strong>spec\today.js</strong> ..</p> <pre><code>describe('Today print', function() { var date = {}, today; beforeEach(function() { date.today = new Date(2012, 3, 30); today = testr('today', {'util/date': date}); //Here is where the error is thrown }); it('is user-friendly', function() { expect(today.getDateString()).toBe('Today is Monday, 30th April, 2012'); }); }); </code></pre> <p><strong>today.js</strong> .. </p> <pre><code>define(['string', 'util/date'], function(string, date) { return { getDateString: function() { return string.format('Today is %d', date.today); } } }); </code></pre> <p>Is there anybody that have been with the same kind of trouble? . I'm using RequireJS 2.0.6</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload