私の目標は、(ここで説明されているように) grunt-connect-prismを使用して、AngularJS アプリからのサーバー リクエストをキャッチし、分度器 E2E テストのモック データとして使用することです。
または、Grunt 用のより優れたサーバー モック データ ライブラリの提案を探しています。
このプロジェクトはまだ始まったばかりですが、とにかく問題を投稿したいと思いました: モック データを保存できません。Grunt サーバーを起動すると、プリズムが実行されていることがわかりますが、それでも保存されません。著者の投稿のコメントから、人々が「コンテキスト」変数をルートとして実行しようとしていたことを読みました。これは、サーバー API の実行元です。そのため、/campaigns エンドポイントからの記録のみを試みましたが、うまくいきませんでした。
$グラントサーバー
「サーバー」タスクの実行
...
「prism」タスクの実行 Prism created for: /campaigns/ to localhost:8888
...
ヘルプ!?!?
// Gruntfile.js
grunt.initConfig({
connect: {
server: {
options: {
keepalive: true,
hostname: '*',
port: 8888,
base: '.tmp',
middleware: function(connect, options) {
return [
require('grunt-connect-prism/middleware'), // will
modRewrite(['!\\.?(js|css|html|eot|svg|ttf|woff|otf|css|png|jpg|gif|ico) / [L]']),
mountFolder(connect, '.tmp'),
];
}
}
}
},
prism: {
options: {
mode: 'record',
mocksPath: './mocks',
// server
host: 'localhost',
port: 8888,
https: false,
// client
context: '/campaigns/',
}
},
// more stuff I removed
});
// development
grunt.registerTask('server', function() {
grunt.task.run([
'stuff ...'
'prism',
'stuff ...',
]);
});
// more stuff I removed
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-connect-prism');