Skip to content

Instantly share code, notes, and snippets.

@Ianfeather
Last active December 19, 2015 12:38
Show Gist options
  • Save Ianfeather/5955858 to your computer and use it in GitHub Desktop.
Save Ianfeather/5955858 to your computer and use it in GitHub Desktop.
Is there a way to make the jasmine src property honour the requirejs baseUrl?
// When I specify our baseUrl as '/public/assets/javascripts'
//
// Grunt will fail to import any files from here ('public/assets/javascripts/lib/**/*.js') into the require call, presumably becaus it is searching in ./lib/**/ which doesn't exist.
// Obviously the specs won't run because there are no src files to test against
jasmine: {
avocado: {
src: ['lib/**/*.js'],
options: {
helpers: './spec/javascripts/helpers/**/*.js',
host: 'http://localhost:8888/',
specs: 'public/assets/javascripts/spec/**/*.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: './public/assets/javascripts/'
}
}
}
}
}
// When the baseUrl is '/'
//
// Grunt will import all the files from here ('public/assets/javascripts/lib/**/*.js') into the require call successfully.
//
// But, because the require calls within the specs are using a baseUrl of public/assets/javascripts/ certain modules are called using two definitions. ie:
// public/assets/javascripts/lib/components/filter.js
// lib/components/filter.js
//
// which leads to this requirejs error: timeout: Load timeout for modules: lib/components/filter
jasmine: {
avocado: {
src: ['public/assets/javascripts/lib/**/*.js'],
options: {
helpers: './spec/javascripts/helpers/**/*.js',
host: 'http://localhost:8888/',
specs: 'public/assets/javascripts/spec/**/*.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: '/'
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment