twolfson / karma-electron

Karma launcher and preprocessor for Electron
The Unlicense
59 stars 21 forks source link

exports is not defined #7

Closed fallenleavesguy closed 8 years ago

fallenleavesguy commented 8 years ago

here is the error:

Electron 1.2.1 (Node 6.1.0) ERROR
  Uncaught ReferenceError: exports is not defined
  at ./node_modules/jasmine-core/lib/jasmine-core/jasmine.js:32

electron has module.exports, but exports is undefined. how should I solve this error? Thanks

fallenleavesguy commented 8 years ago

here is my karma config:

// Karma configuration
// Generated on Mon Jun 20 2016 10:18:43 GMT+0800 (CST)

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: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
        'app/rp/modules/app.js',
        'test/unit/**/*.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: {
      '**/*.js': ['electron']
    },

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

    // 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: ['Electron'],

    // 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
  })
}
fallenleavesguy commented 8 years ago

I have fixed it by do this

npm install git+https://github.com/jasmine/jasmine.git#master --save-dev

jasmine have fixed this, but npm version is wrong at line 26 of file 'jasmine/lib/jasmine-core/jasmine.js':

wrong version:

if (typeof module !== 'undefined' && module.exports) {

right version:

if (typeof module !== 'undefined' && module.exports && typeof exports !== 'undefined') {
twolfson commented 8 years ago

Please see https://github.com/twolfson/karma-electron/blob/3.2.1/docs/submodules.md It's more likely a submodules issue that is arising.