Pregunta

I've installed karma. I've created a karma.conf.js file and pointed to my source files. In my source files is included a version of require.js.

Everything seems fine (it launches the node server, and Webstorm CLI connects to it properly) except it barfs when loading backbone style files that begin with define(... In my output I get

Uncaught ReferenceError: define is not defined
at http://localhost:9876/base/src/main/app/App.js?f2880b74f1e96a210ff36e8394daa946c9d11294:1

When I jump to code, the line indicated is just define( at the top of a backbone js file.

I've tried explicitly including require in my lib directory (which should have already been included from the wildcard)

Do I need some boilerplate somewhere to not muddle (possibly conflicting) require.js's? I tried ignoring require... but the result was the same.

 exclude: [
      '**/*.scss',
      '**/*.css',
      '**/Gruntfile.js',
        '**/docs/*.js',
        '**/main/resources/js/lib/crypto-js-3.1.2/*.js',
        '**/main/resources/js/lib/require-2.1.2.min.js' // same error when ignored
    ],

Only mildly related: I'm running karma from webstorm.

¿Fue útil?

Solución

I believe you have to include 'requirejs' in your frameworks. Make sure you include the requirejs string before others, ie:

    frameworks: ['requirejs','jasmine']
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top