Jasmine + asset paths

We’re wanting to use middleman-jasmine to run some tests on the generated sites: e.g.

  • does the popup contact form appear
  • injecting a GeoIP location does it show the nearest office

We’ve managed to set up Jasmine and it runs a basic trivial test, but I can’t see how to require our source JS libs.

we have this structure:

source
  js
   thing.js

spec
  js
    spec.js
    thing_spec.js

spec.js looks like this:

//= require_tree .
//= require thing

But it can’t find thing. I’ve tried every combination of:

//= require ../../source/js/thing
//= require ../../build/js/thing
//= require js/thing
//= require js/thing.js

None of which work.

What’s the trick here?

Hello @suranyami

Humm I don’t know how Jasmine works but have you tried to use it in your config.rb ?

Here is an example with autoprefixer

As you can see i do some stuff in the build section

# Build-specific configuration
configure :build do
  ...
end

Okay, discovered the problem. It turns out we had the wrong path in config.rb:

set :js_dir, 'js'

We incorrectly had ‘javascripts’ instead of ‘js’.

Strangely, it didn’t affect anything in the rest of the middleman build, but did stop sprockets from finding the asset paths for jasmine.