moment-timezone
moment-timezone copied to clipboard
Question : Injecting moment-timezone to Jasmine testing.
Hi folks,
Can anyone give out some clues on how to inject moment-timezone correct when testing a typescript component (Angular4)?
I get the following error in Jasmine when loading my component
"undefined is not a constructor (evaluating 'moment().tz("America/Sao_Paulo")')"
beforeEach(() => { TestBed.configureTestingModule({ imports: [AppModule, SupportModule, MomentModule] }); TestBed.compileComponents(); }); import { MomentModule } from 'angular2-moment'; import * as moment from 'moment';
If anyone here has implemented tests using the library, I am welcome to suggestions :)
I've been struggling with this as well for roughly a few weeks, have you made any progress?
So far i've been changing everything manually to work..
changed in actual code, not spec.ts
//return date.utc(conserveLocal);
return moment(date).utc(conserveLocal); //changed to this, jasmine couldn't find date.prototype