wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

Type error 'undefined' evaluating 'bard.appModule....' #29

Closed mikeerickson closed 8 years ago

mikeerickson commented 8 years ago

I am trying to get bard up and running with karma, but having issues right away with the appModule method (see below)

Is there a loading hierarchy for bard?

FAILED TESTS:
  LookupTestController
    ✖ "before each" hook for "should say hello"
      PhantomJS 1.9.8 (Linux 0.0.0)
    TypeError: 'undefined' is not a function (evaluating 'bard.appModule('lookup-test')')
        at /var/www/query_tool/web/bundles/test/js/specs/lookup.controller.spec.js:17

Here is my karam.conf.js

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha','chai-as-promised','chai','sinon', 'sinon-chai'],

    files: [

      // add test polyfills (Promise)
      'web/bundles/test/js/Promise.js',
      'web/bundles/test/js/function.bind.polyfill.js',

      // module dependencies and angular mocks library
      'node_modules/angular/angular.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'node_modules/angular-ui-select/select.js',
      'node_modules/bardjs/dist/bard.min.js',

      // add each js file which will be tested
      'web/bundles/test/js/myController.js',

      // testing lookup interface
      'web/bundles/test/js/ng-lodash.js',

      // loads all module dependencies (controller, filter, service, factory)
      'web/bundles/test/js/lookup.*.js',

      // reference spec directory (all specs will be run)
      'web/bundles/test/js/specs/**/*.spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress', 'mocha-clean'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}
mikeerickson commented 8 years ago

As an aside, my original beforeEach (without bard) is as follows (and works fine)

  beforeEach(function() {
    module('lookup-test');
    inject(function($controller, _$log_, _$timeout_, _$q_, lookupService) {
      $log       = _$log_;
      $timeout   = _$timeout_;
      $q         = _$q_;
      controller = $controller('LookupTestController');
    });
  });
mikeerickson commented 8 years ago

Well, on a whim I decided to try the un-minified version and now it works. In my karma.conf.js file, I changed

      // module dependencies and angular mocks library
      'node_modules/angular/angular.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'node_modules/angular-ui-select/select.js',
      'node_modules/bardjs/dist/bard.min.js',

to

      // module dependencies and angular mocks library
      'node_modules/angular/angular.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'node_modules/angular-ui-select/select.js',
      'node_modules/bardjs/dist/bard.js',