Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to link my application #5

Open
TestDS1 opened this issue Apr 7, 2015 · 3 comments
Open

How to link my application #5

TestDS1 opened this issue Apr 7, 2015 · 3 comments

Comments

@TestDS1
Copy link

TestDS1 commented Apr 7, 2015

Hello, I'm trying to run your plugin, but I need help.

My structure:

build-dev/      <-- Generated by grunt
    vendor/
        js/
            jquery.js
           require.js
    js/
        model/
            cache.js     <-- File to be tested
        tests/
            cache.js    <-- Test for a file
        tests.js       <-- like test-bootstrap.js

My gruntfile config is:

mocha_require_phantom:
    devel:
        options:
            base: 'build-dev/js'
            main: 'tests'
            requireLib: '../vendor/js/require.js'
            files: ['tests/**/*.js']
            port: 3001

My tests.js (test-bootstrap.js) is:

require.config({
  paths: {
    jquery: '../vendor/js/jquery',
    chai: '/node_modules/chai/chai'
  },
  baseUrl: '/'
});

mocha.setup({
  ui: 'bdd'
});

require([testPathname], function() {
  if (window.mochaPhantomJS) {
    return mochaPhantomJS.run();
  } else {
    return mocha.run();
  }
});

My tests/cache.js is:

define(['chai', 'model/cache'], function(chai, cache) {
  var should;
  should = chai.should();
  return describe('test suite 1', function() {
    return it('should work', function() {
      return cache.test().should.be.equal(5);
    });
  });
});

The problem is it's not working. It can't load model/cache. I was trying to change baseUrl in tests.js (like test-bootstrap.js). I was also trying to change baseUrl in grunt. I was trying to add path: 'model: ../../js/model', but it was ignored.

I need to call for a model as 'model/cache', how do I have to set up things to make it work?

@accordionpeas
Copy link
Owner

Hi,

I notice you've got '../vendor/js/require.js' set as your requireLib property but your directory name is "vendors". I realise that might be a typo in your issue description but thought I'd check before I look into this deeply.

Mike

@TestDS1
Copy link
Author

TestDS1 commented Apr 7, 2015

Thank you very much for answer. It's a typo, wen I was formating my input, I'm sorry for that. It works fine without dependency (model/test), it works fine when I call dependency like:

define(['chai', '../../js/model/cache'], function(chai, cache) {

But it's not working the way I need it to work :)

EDIT: I edited my question.

@vass-david
Copy link

In tests/cache.js you are including 'model/cache' which is relative to '/js' path. Shouldn't baseUrl in your requirejs config be '/js'?

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

No branches or pull requests

3 participants