Skip to content

Conversation

@CraigCav
Copy link

Rather than copy-pasting the requirejs.config paths and shims into the require.config for running tests, we can just load the applications requirejs configuration from test-main.js.

This PR was inspired by @jugglinmike's blog post on Effective Unit Testing with AMD.

@uuilee
Copy link

uuilee commented Mar 11, 2014

Does that work with the paths defined in require-config? It seems to me that if require-config.js defines a baseUrl (js) with paths and test-main.js defines a different baseUrl (base/js) the paths defined in require-config.js can't be used in the tests, as they will be served at base/js but the paths point to modules located at js.

@jugglinmike
Copy link

@uuilee Check out that article Craig referenced :)

@uuilee
Copy link

uuilee commented Mar 17, 2014

@jugglinmike, thanks fot the reference.
For some reason I can't get my tests to work using:

require.config({
  baseUrl: '/base/js',
  deps: ['/base/js/src/config.js'],
  callback: function() {
    'use strict';
    require(tests, window.__karma__.start);
  }
});

instead i had to do the following:

require(['/base/js/src/config.js'], function() {
  'use strict';
  require.config({
    baseUrl: '/base/js',
    callback: function() {
      require(tests, window.__karma__.start);
    }
  });
});

In the former, it seemed that the baseUrl did not get properly overriden to /base/js.

@RubenCordeiro
Copy link

This really should be merged, as it simplifies the setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants