Przygotowywałem sepię do użycia z kątomierzem. To działa teraz, oto co zrobiłem:
Zakładam, że już skonfigurowałeś grunt-connect, aby uruchomić testy kątomierza.
Następnie trzeba poczekać na Zdarzenie słuchać od connect konfiguracji: grunt.event.once('connect.test.listening', function)
I to gdzie można skonfigurować sepia.
grunt.event.once('connect.test.listening', function(host, port) {
/**
* Configure sepia here
*/
var sepia = require('sepia').withSepiaServer();
// Use your custom configuration
sepia.configure({
verbose: true,
debug: true,
includeHeaderNames: false,
includeCookieNames: false
});
// I have some path/body content to filter configured in the vrc configuration
var bodyFilters = grunt.config('vcr.filters.body') || [];
var pathFilters = grunt.config('vcr.filters.path') || [];
var regexPath = function(string) {
var escapedString = string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
return new RegExp(escapedString);
};
// Filter path
_.map(pathFilters, function(filter) {
sepia.filter({
url: regexPath(filter.path),
urlFilter: function(url) {
return url.replace(filter.pattern, filter.replacement);
}
});
});
// Filter body content
_.map(bodyFilters, function(filter) {
sepia.filter({
url: regexPath(filter.path),
bodyFilter: function(body) {
return body.replace(filter.pattern, filter.replacement);
}
});
});
});
});
Znalazłeś coś? Byłoby to pomocne dla tego, co próbuję zrobić. –
Do tej pory używam kątnicy-makiety, ale wymaga to wklejenia odpowiedzi od inspektora. nie jest tak gładki, jakbym chciał. –