2015-10-29 2 views
1

Утро,название модуля «водопроводная» нарушение кармы тестирование

Я разрабатываю новый набор тестов Карма на манекен приложения, но ударил-бит блокпоста. Я инициализирован файл karma.conf.js, но когда я запускаю карму я получаю следующее сообщение об ошибке:

Uncaught Error: Module name "tap" has not been loaded yet for context:  
_. Use require([]) 
http://requirejs.org/docs/errors.html#notloaded 
at 
/Users/Andrew/sites/mine/FlowMyAngular/node_modules/requirejs/require.js:140 

Я пошел на сайт requirejs и объяснил следующее:

This occurs when there is a require('name') call, but the 'name' module has not been loaded yet.

If the error message includes Use require([]), then it was a top-level require call (not a require call inside a define() call) that should be using the async, callback version of require to load the code

Ok - но дело в том, что я не могу найти, где это требует действия, происходящего в коде - широкомасштабный поиск проекта для него не возвращал ничего. Все, что я знаю о кране, это то, что это каркас, который можно использовать в карме для вывода TAP с ленты.

Неужели кто-нибудь еще встретил эту ошибку или знает, как я могу обойти ее? Вот мой karma.conf.js файл:

// Karma configuration 
// Generated on Thu Oct 29 2015 09:59:59 GMT+0000 (GMT) 

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: [ 
     'node_modules/requirejs/require.js', 
     '**/*.test.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'], 


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


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

    // Concurrency level 
    // how many browser should be started simultanous 
    concurrency: Infinity 
    }) 
} 

ответ

3

Оказывается, проблема на самом деле произошло из-за того, что я устанавливал в файле karma.conf.js расположения тестов. Эта линия:

'**/*.test.js', 

по существу пытается тянуть нежелательные/ненужные файлы при запуске кармы приводит к ошибке, описанной выше. Одним из решений этого может быть перенос всех модульных тестов в одну папку, однако это будет противоречить лучшей практике, когда дело доходит до структуры проекта.

Чтобы исправить это я сохранил все мои тесты вместе с кодом они тестирование и изменил строку:

'app/js/**/*.test.js' 

работы.

Смежные вопросы