recommend using DI approach from other answers instead of this approach
You should be able to use the class directly
new DatePipe().transform(myDate, 'yyyy-MM-dd');
For instance
var raw = new Date(2015, 1, 12);
var formatted = new DatePipe().transform(raw, 'yyyy-MM-dd');
expect(formatted).toEqual('2015-02-12');