I am stuck now for a while trying to get unit testing set up and runnning.

I have an AngularJS front-end loaded with RequireJS and r.js optimized for production, so it's all nicely in one single file. This works!

What doesn't work is getting the unit tests executed. This is nothing fancy so far, just copied a starter from a tutorial.

`tests/user/user.test.js`:

```
define(['angular', 'angular-mocks', 'app'], function(angular, app) {
  describe('Unit: UserController', function() {
    beforeEach(module('user.app'));

    it('should do something', function() {
      console.log('did it');
    });
  });
});

```

Then I have a `karma.conf.js`:

```
module.exports = function(config) {
  config.set({
    logLevel: config.LOG_DEBUG,
    basePath: './',

    files: [
      // r.js'd app files
      {pattern: 'dist/app.js', included: false},
      // the tests
      {pattern: 'tests/**/*.test.js', included: true},
    ],

    excluded: ['tests/main.test.js']

    frameworks: ['jasmine', 'requirejs'],

    browsers: ['PhantomJS'],

    plugins: [
      'karma-jasmine',
      'karma-junit-reporter',
      'karma-phantomjs-launcher',
      'karma-requirejs'
    ],

  });
};

```

A `main.test.js`:

```
var allTestFiles = [];
var TEST_REGEXP = /(spec|test)\.js$/i;

var pathToModule = function(path) {
  var returnValue = path.replace(/^\/base\//, '').replace(/\.js$/, '');
  return returnValue;
};

Object.keys(window.__karma__.files).forEach(function(file) {
  if (TEST_REGEXP.test(file)) {
    // Normalize paths to RequireJS module names.
    allTestFiles.push(pathToModule(file));
  }
});

require.config({
  baseUrl: '/base',

  paths: {
    'angular-mocks': 'node_modules/angular-mocks/angular-mocks',
    'app': 'dist/app',
  },

  deps: allTestFiles,

  callback: function() {
    console.log('load complete');
    window.__karma__.start();
  },
});

```

And finally a `gulp` task:

```
var gulp  = require('gulp');
var karma = require('karma').server;

gulp.task('unit-test', function(done) {
  karma.start({
    configFile: __dirname + '/karma.conf.js',
      singleRun: true
   }, function() { done(); });
}

```

Here and there I added some log outputs and it shows that the files are loaded.

But I am stuck getting this `Error: Mismatched anonymous define()` in the `tests/user/user.test.js` and I don't see what is wrong. Here is the output:
<http://pastebin.com/evJPj9B3>

If I name the unit test module like

```
define('namedtestorso', ['angular', 'angular-mocks', 'app'], function(angular, app) {
  ...

```

... I don't get an error any more but the tests are not executed. Since all examples I can recall use it as anonymous define I assume naming is not correct here. But in that case the log output is executed showing that the config callback from `main.test.js` is executed twice. (Is that a hint for something?)

Would be great if anyone has an idea how to fix it/get it running or even how to go on finding out what's wrong. Thanks in advance!