0

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?

2
  • Is it a typo in your sample only ['modules/error']function ? Commented Jun 4, 2013 at 8:42
  • 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. Commented Jun 4, 2013 at 8:47

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.