0
votes

My directory structure looks something like this:

\js
   ...
   \models\...
   ...
   \test
        \test_runner.js
        \error_test.js
        ...
   main_tests.js

Where I have the following code in main_tests.js:

requirejs(['test/test_runner'],function(){
  console.log('Testing begins');
});

The test_runner.js looks like this:

define('test_runner',['test/error_test'],function(){
   console.log("in test_runner");
});

and the error_test.js is like this:

define('error_test',['modules/error'],function() {
   console.log('in erro_test');
});

As you might have figured out I want to run from the test_runner.js some tests. I need main_tests.js in order to define the dependencies for the application to be tested. I can set up the application to work(it's ember based). When I run the code for the tests it loads the test_runner.js, but it does not execute it and it also doesn't loads its dependencies(error_test.js).

Any thoughts why it does not do the thing?

1
Is it a typo in your sample only ['modules/error']function ?claustrofob
yes, I'll correct it - thanks, but it does not affect my problem, since as I said, that part of the app does not even load.Pio

1 Answers

1
votes

In requireJS you've redefined 'test/test_runner' module as 'test_runner'

You should define test_runner.js without renaming the module:

define(['test/error_test'], function(){
   console.log("in test_runner");
});

As a rule of thumb, models should be referred to by their full path & name. They shouldn't be renamed by passing in the 1st param.

See the official docs