2015-07-28 10 views
5

मेरे पास एक कोणीय परियोजना है और मैं परीक्षण चलाने के लिए कर्म का उपयोग कर रहा हूं। मैं इसके साथ कुछ समस्याओं में चला रहा हूँ, यह त्रुटि मिलती:त्रुटि: "ढांचे: ब्राउज़रीकरण" के लिए कोई प्रदाता नहीं! (हल करना: ढांचा: ब्राउज़र बनाना)

ReferenceError: Can't find variable: require 
at http://localhost:9876/base/src/test/bower_components/angular-animate/index.js?b8fe1c0a06b723a75c7e596fd8a86d91965f681c:1 

कुछ मंचों में Reding, मैं, कर्म browserify उपयोग करने के लिए कहा गया था, लेकिन मैं इस त्रुटि अब हो रही है:

28 07 2015 22:41:15.573:WARN [preprocess]: Can not load "browserify", it is not registered! 
     Perhaps you are missing some plugin? 
    /Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/node_modules/di/lib/injector.js:9 
      throw error('No provider for "' + name + '"!'); 
       ^
    Error: No provider for "framework:browserify"! (Resolving: framework:browserify) 
     at error (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/node_modules/di/lib/injector.js:22:68) 
     at Object.parent.get (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/node_modules/di/lib/injector.js:9:13) 
     at get (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/node_modules/di/lib/injector.js:54:19) 
     at /Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/lib/server.js:128:20 
     at Array.forEach (native) 
     at Server._start (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/lib/server.js:127:21) 
     at invoke (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/node_modules/di/lib/injector.js:75:15) 
     at Server.start (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/lib/server.js:92:18) 
     at Function.Server.start (/Users/brunosiqueira/WebstormProjects/copcast-admin/node_modules/karma/lib/server.js:101:10) 
     at Object.<anonymous> (/Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js:10:8) 
     at Module._compile (module.js:460:26) 
     at Object.Module._extensions..js (module.js:478:10) 
     at Module.load (module.js:355:32) 
     at Function.Module._load (module.js:310:12) 
     at Function.Module.runMain (module.js:501:10) 
     at startup (node.js:129:16) 

किसी को भी करता है पता है कि क्या हो रहा है?

{ 
     // Karma configuration 
     // Generated on Tue May 19 2015 15:02:17 GMT+0100 (WEST) 

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

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

      plugins: [ 
      'karma-browserify', 
      'karma-phantomjs-launcher', 
      'karma-jasmine', 
      'karma-ng-html2js-preprocessor', 
      'karma-spec-reporter' 

      ], 

      // testing framework to use (jasmine/mocha/qunit/...) 
      frameworks: [ 'browserify','jasmine'], 

      // list of files/patterns to load in the browser 
      files: [ 
      'http://maps.googleapis.com/maps/api/js?sensor=false&language=en', 
      // bower:js 
      'bower_components/jquery/dist/jquery.js', 
      'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js', 
      'bower_components/bootstrap-select/dist/js/bootstrap-select.js', 
      'bower_components/angular/angular.js', 
      'bower_components/angular-animate/angular-animate.js', 
      'bower_components/angular-cookies/angular-cookies.js', 
      'bower_components/angular-touch/angular-touch.js', 
      'bower_components/angular-sanitize/angular-sanitize.js', 
      'bower_components/angular-resource/angular-resource.js', 
      'bower_components/angular-route/angular-route.js', 
      'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', 
      'bower_components/angular-ui-utils/ui-utils.js', 
      'bower_components/angular-ui-map/ui-map.js', 
      'bower_components/angular-http-auth/src/http-auth-interceptor.js', 
      'bower_components/ng-file-upload/ng-file-upload.js', 
      'bower_components/ng-file-upload-shim/ng-file-upload-shim.js', 
      'bower_components/angular-notify/dist/angular-notify.js', 
      'bower_components/moment/moment.js', 
      'bower_components/angular-gettext/dist/angular-gettext.js', 
      // endbower 
      'src/app/**/*.js', 
      'src/app/views/**/*.html', 
      'src/test/**/*.js' 
      ], 

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

      // preprocess matching files before serving them to the browser 
      // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 
      preprocessors: { 
      '**/*.html': ['ng-html2js'], 
      '**/*.js': [ 'browserify' ] 
      }, 
      ngHtml2JsPreprocessor: { 
      // strip this from the file path 
      stripPrefix: 'src/', 
      // prepend this to the 


      // setting this option will create only a single module that contains templates 
      // from all the files, so you can load them all with module('foo') 
      moduleName: 'templatesForTest' 
      }, 

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


      // 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 
     }); 
     }; 

    } 
+0

मूल उदाहरण को देखते हुए मैं कहूंगा कि आपने ब्राउज़र संदेश को कॉन्फ़िगर करना समाप्त नहीं किया है जैसे त्रुटि संदेश कहता है। https://www.npmjs.com/package/karma-browserify –

+0

क्या आपने 'npm इंस्टॉल - सेव-देव कर्म-ब्राउज़रify' की कोशिश की है? – mostruash

उत्तर

1

मैं पुस्तकालयों के विभिन्न संस्करणों के साथ कुछ समस्या थी: यह मेरा karma.conf फ़ाइल है।

मेरे package.json फ़ाइल:

"karma": "0.12.0", 
"karma-html2js-preprocessor": "0.1.0", 
"karma-jade-preprocessor": "0.0.11", 
"karma-jasmine": "0.1.5", 
"karma-ng-html2js-preprocessor": "0.1.2", 
"karma-phantomjs-launcher": "0.1.4", 
"karma-requirejs": "0.2.1", 
"karma-script-launcher": "0.1.0", 
"karma-coffee-preprocessor": "0.2.1", 

"brfs": "^1.2.0", 
"browserify-shim": "~3.8.0", 
"karma-browserify": "^3.0.0", 

मेरे karma.conf.js फ़ाइल:

// Karma configuration 
// Generated on Tue May 19 2015 15:02:17 GMT+0100 (WEST) 
module.exports = function(config) { 
    config.set({ 

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

// testing framework to use (jasmine/mocha/qunit/...) 
frameworks: [ 'jasmine', 'browserify'], 

// list of files/patterns to load in the browser 
files: [ 
    'http://maps.googleapis.com/maps/api/js?sensor=false&language=en', 
    // bower:js 
    'bower_components/jquery/dist/jquery.js', 
    'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js', 
    'bower_components/bootstrap-select/dist/js/bootstrap-select.js', 
    'bower_components/angular/angular.js', 
    'bower_components/angular-animate/angular-animate.js', 
    'bower_components/angular-cookies/angular-cookies.js', 
    'bower_components/angular-touch/angular-touch.js', 
    'bower_components/angular-sanitize/angular-sanitize.js', 
    'bower_components/angular-resource/angular-resource.js', 
    'bower_components/angular-route/angular-route.js', 
    'bower_components/angular-mocks/angular-mocks.js', 
    'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', 
    'bower_components/angular-ui-utils/ui-utils.js', 
    'bower_components/angular-ui-map/ui-map.js', 
    'bower_components/angular-http-auth/src/http-auth-interceptor.js', 
    'bower_components/ng-file-upload/ng-file-upload.js', 
    'bower_components/ng-file-upload-shim/ng-file-upload-shim.js', 
    'bower_components/angular-notify/dist/angular-notify.js', 
    'bower_components/moment/moment.js', 
    'bower_components/angular-gettext/dist/angular-gettext.js', 
    // endbower 
    'src/app/**/*.js', 
    'src/app/views/**/*.html', 
    'src/test/**/*.js' 
], 

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

// preprocess matching files before serving them to the browser 
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 
preprocessors: { 
    '**/*.html': ['ng-html2js'], 
    'src/**/*.js': ['browserify'] 
}, 

browserify: { 
    debug: true, 
    transform: [ 'brfs' ] 
}, 
ngHtml2JsPreprocessor: { 
    // strip this from the file path 
    stripPrefix: 'src/', 
    // prepend this to the 


    // setting this option will create only a single module that contains templates 
    // from all the files, so you can load them all with module('foo') 
    moduleName: 'templatesForTest' 
}, 

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


// 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 
    }); 
}; 

अद्यतन

लेकिन अंत में, मैं इस तरह काम करने के लिए बनाने के लिए मिला

मैंने हाल ही में अपने सभी पुस्तकालयों को हाल के संस्करण में अपडेट किया है और मुझे यह त्रुटि फिर से मिली है। मुझे एहसास हुआ कि मैं लाइब्रेरी ब्राउज़र को याद कर रहा था और खुद को देख रहा था। तो मैंने दो लापता पुस्तकालयों को स्थापित किया और सब कुछ पूरी तरह से काम किया।

Warning: No provider for "framework:mocha"! (Resolving: framework:mocha)

ऐसा इसलिए हुआ क्योंकि मैं प्लगइन शामिल नहीं किया था:

npm install --save-dev karma-browserify browserify watchify 
1

मैं एक ऐसी ही समस्या थी। सही config:,

npm install karma-mocha --save-dev 

https://www.npmjs.com/package/karma-mocha


आगे प्रयोग करने के बाद लगता है कि इस त्रुटि को जन्म दिया संदेश है:

... 
singleRun: true, 
plugins: ['karma-phantomjs-launcher', 'karma-mocha'], // here 
frameworks: ['mocha'], 
... 

इसके अलावा उल्लेख के लायक है, तो आप प्लगइन स्थापित करने की आवश्यकता होगी जब आपने निर्दिष्ट फ्रेमवर्क के लिए प्लगइन शामिल नहीं किया है:

... 
plugins: ['karma-phantomjs-launcher', 'karma-mocha', 'karma-chai'], 
frameworks: ['mocha', 'chai'], // Will require the plugins above 
... 
संबंधित मुद्दे