2016-05-01 6 views
2

が見つかりません「分度器」タスクのために私はヨーマン/イサキ/亭に新しいですし、私はangularjsプロジェクトをセットアップに取り組んでいます:うなり声:JIT-作男:プラグイン

yo angular 

私はいくつかの変更を加えました自分自身をgruntfileに、最近私は非常に便利な分度器を発見し、私は自分のプロジェクトにそれを追加したい。私は多くの指示をオンラインで(この1のようにIntegrating Protractor with Yeoman via Grunt 2年前に)続けましたが、私は引き分け器を正しく取り付けることができません。ここで

は私Gruntfile.js次のとおりです(関連部分のみを示した)

'use strict'; 
module.exports = function (grunt) { 

    // Time how long tasks take. Can help when optimizing build times 
    require('time-grunt')(grunt); 

    // Automatically load required Grunt tasks 
    require('jit-grunt')(grunt, { 
    useminPrepare: 'grunt-usemin', 
    ngtemplates: 'grunt-angular-templates', 
    cdnify: 'grunt-google-cdn' 
    }); 

    // Configurable paths for the application 
    var appConfig = { 
    app: require('./bower.json').appPath || 'app', 
    dist: 'dist' 
    }; 

    // Define the configuration for all the tasks 
    grunt.initConfig({ 

    // Project settings 
    yeoman: appConfig, 

    ... 
    ... 

    // Automatically inject Bower components into the app 
    wiredep: { 
     app: { 
     src: ['<%= yeoman.app %>/index.html'], 
     ignorePath: /\.\.\// 
     }, 
     test: { 
     devDependencies: true, 
     src: '<%= karma.unit.configFile %>', 
     ignorePath: /\.\.\//, 
     fileTypes:{ 
      js: { 
      block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi, 
       detect: { 
       js: /'(.*\.js)'/gi 
       }, 
       replace: { 
       js: '\'{{filePath}}\',' 
       } 
      } 
      } 
     }, 
     sass: { 
     src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'], 
     ignorePath: /(\.\.\/){1,2}bower_components\// 
     } 
    }, 

    ... 
    ... 

    // Test settings 

    karma: { 
     unit: { 
     configFile: 'test/karma.conf.js', 
     singleRun: true 
     } 
    }, 

    protractor: { 
     options: { 
     keepalive: true, 
     configFile: 'protractor.conf.js' 
     }, 
     run: {} 
    } 

    }); 

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { 
    if (target === 'dist') { 
     return grunt.task.run(['build', 'connect:dist:keepalive']); 
    } 

    grunt.task.run([ 
     'clean:server', 
     'wiredep', 
     'concurrent:server', 
     'postcss:server', 
     'connect:livereload', 
     'watch' 
    ]); 
    }); 

    grunt.registerTask('test', [ 
    'clean:server', 
    'wiredep', 
    'concurrent:test', 
    'postcss', 
    'connect:test', 
    'karma', 
    'protractor:run' 
    ]); 
}; 

ここに私のpackage.jsonです:

{ 
    "name": "Website", 
    "private": true, 
    "devDependencies": { 
    "autoprefixer-core": "^5.2.1", 
    "compass": "^0.1.1", 
    "grunt": "^0.4.5", 
    "grunt-angular-templates": "^0.5.7", 
    "grunt-concurrent": "^1.0.0", 
    "grunt-contrib-clean": "^0.6.0", 
    "grunt-contrib-compass": "^1.0.0", 
    "grunt-contrib-concat": "^0.5.0", 
    "grunt-contrib-connect": "^0.9.0", 
    "grunt-contrib-copy": "^0.7.0", 
    "grunt-contrib-cssmin": "^0.12.0", 
    "grunt-contrib-htmlmin": "^0.4.0", 
    "grunt-contrib-imagemin": "^1.0.0", 
    "grunt-contrib-jshint": "^0.11.0", 
    "grunt-contrib-uglify": "^0.7.0", 
    "grunt-contrib-watch": "^0.6.1", 
    "grunt-filerev": "^2.1.2", 
    "grunt-google-cdn": "^0.4.3", 
    "grunt-jscs": "^1.8.0", 
    "grunt-karma": "^0.12.2", 
    "grunt-newer": "^1.1.0", 
    "grunt-ng-annotate": "^0.9.2", 
    "grunt-postcss": "^0.5.5", 
    "grunt-protractor-runner": "^3.0.0", 
    "grunt-svgmin": "^2.0.0", 
    "grunt-usemin": "^3.0.0", 
    "grunt-wiredep": "^2.0.0", 
    "jasmine-core": "^2.4.1", 
    "jit-grunt": "^0.9.1", 
    "jshint-stylish": "^1.0.0", 
    "karma": "^0.13.22", 
    "karma-jasmine": "^0.3.8", 
    "karma-phantomjs-launcher": "^1.0.0", 
    "karma2": "^0.13.22", 
    "phantomjs-prebuilt": "^2.1.7", 
    "protractor": "^3.0.0", 
    "time-grunt": "^1.0.0" 
    }, 
    "engines": { 
    "node": ">=0.10.0" 
    }, 
    "scripts": { 
    "test": "karma start test/karma.conf.js", 
    "install": "node node_modules/protractor/bin/webdriver-manager update" 
    }, 
    "dependencies": {} 
} 

私は(今デフォルトとして)jit-gruntを使用ので、それは私のために、これらのプラグインをロードします。

私は確かに私は上記のポストとprotractorgrunt-protractor-runnerの公式サイトなどのほかの情報源次protractorgrunt-protractor-runnerがインストールされています。私の地元のnode_modulesで:

$ ls node_modules/ | grep protractor 
grunt-protractor-runner 
protractor 

しかし、関係なく、私は何をすべきか、私はまだイサキからエラーを取得していない午前:

$ grunt protractor 

jit-grunt: Plugin for the "protractor" task not found. 
If you have installed the plugin already, please setting the static mapping. 
See https://github.com/shootaroo/jit-grunt#static-mappings 

Warning: Task "protractor" failed. Use --force to continue. 

そして、イサキのテストを実行している:

$ grunt test 

Running "clean:server" (clean) task 
>> 1 path cleaned. 

... 
... 

Running "karma:unit" (karma) task 
01 05 2016 15:03:51.048:WARN [watcher]: Pattern 
01 05 2016 15:03:51.094:INFO [karma]: Karma v0.13.22 server started at http://localhost:8080/ 
01 05 2016 15:03:51.112:INFO [launcher]: Starting browser PhantomJS 
01 05 2016 15:03:52.259:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#68w8QMUehAm8AAf2AAAA with id 17032121 
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 2 of 2 SUCCESS (0.003 secs/0.026 secs) 

jit-grunt: Plugin for the "protractor" task not found. 
If you have installed the plugin already, please setting the static mapping. 
See https://github.com/shootaroo/jit-grunt#static-mappings 

Warning: Task "protractor:run" failed. Use --force to continue. 

Aborted due to warnings. 

は何かがあります私は逃した?私は数日間このことに固執しています。どんな助けも大歓迎です。

+1

'JIT-grunt'を削除した場合、正しく動作しますか? – theaccordance

+0

@ありがとうございました! JIT-gruntを無効にした後、Npmタスクをロードしようとしていました。私は手動で「グラント・ピラー・ランナー」をロードする必要があることを知りました。今分度器が正常に動作していたようだ! (少なくともそれは尻込みで見つけられる。ありがとう! – Fei

答えて

1

@theaccordanceの提案とヒントをありがとう。 JIT-gruntには、おそらくgrunt-protractor-runnerの読み込みに問題があることがわかります。

grunt.loadNpmTasks('grunt-protractor-runner');をGruntfile.jsに追加すると問題が解決されます。

0

受け入れられた回答はアンチパターンに従い、GruntのJIT(Just In Time)プラグインローダーの目的を破っています。

jit-gruntの目的は、必要なプラグインを自動的にロードすることで、grunt.loadNpmTasksの使用を廃止します。 jit-gruntため

documentationは、プラグインローダーは、プラグインを探している方法について説明します。

は、自動的にタスク名からプラグインを検索します。あなた以来

  1. node_modules /作男-contribのタスク名
  2. node_modules /作男タスク名
  3. node_modules /タスク名

: 次の順序で検索しますprotractorというタスクがある場合、プラグインローダーは対応するプラグインを次の順序で見つけようとします:

  1. grunt-contrib-protractor
    • packages.json
  2. protractor
      に存在しない packages.json
  3. grunt-protractor
    • に存在しません
    • packages.jsonに見つかりました!
    • 残念なことにミスマッチ
    • タスクprotractorに必要なプラグインがエラー・メッセージが指摘するように、我々は、静的マッピングを設定することができ、この場合grunt-protractor-runner

あるがあります。これは古い質問です

// Automatically load required Grunt tasks 
require('jit-grunt')(grunt, { 
    useminPrepare: 'grunt-usemin', 
    ngtemplates: 'grunt-angular-templates', 
    cdnify: 'grunt-google-cdn', 
    protractor: 'grunt-protractor-runner' 
});

が、私は私の答えは、この問題が発生した他の人々を助けることを願って:grunt_plugin_name:私たちは形式tasknameでこれを行います。

関連する問題