を使用して、エラーmoment.momentを得ることが...私はmoment.jsと接続詞にジャスミンをしようとしていますが、私はこのエラーを取得していますジャスミンとMoment.js
debug.js:21 Uncaught TypeError: (0 , _moment.moment) is not a function
ないように注意してください関数ではありませんそれがmoment.jsに関連している場合、または私がこれを間違って設定している場合。助けをお待ちしています。
//script.js
import { moment } from 'moment';
export class Age {
constructor(age, secondDate) {
this.age = age;
this.secondDate = secondDate;
}
getSecondsBetweenTwoDates(age, secondDate){
age = moment(this.age).format('l');
secondDate = moment(this.secondDate).format('l');
//differenceInSeconds = moment((this.secondDate).diff(this.age, 'days'));
differenceInDays = age.diff(secondDate, 'days');
//let differenceInDays = this.age - this.secondDate
return differenceInDays;
}
}
//age-spec.js
import { Age } from './../js/age.js';
describe('Age', function() {
let reusableDate,
today,
testDate = '2016-10-05',
date = '2016-10-10';
beforeEach(() => {
reusableDate = new Age(date, testDate);
console.log(reusableDate);
const mockedDateAndTime = '2017-03-02 00:00:00';
today = moment(mockedDateAndTime).toDate();
console.log('this is today', today);
jasmine.clock().mockDate(today);
});
it('should return the difference between today',() => {
console.log(date);
console.log(testDate);
console.log(reusableDate.getSecondsBetweenTwoDates(date, testDate));
console.log(typeof(reusableDate.getSecondsBetweenTwoDates));
//expect(5).toEqual(reusableDate.getSecondsBetweenTwoDates());
});
});
私は全くbeforeEachブロックを使用していない、それは私がGoogleで見つかった、としようとしていただけのものだった...私もそうのようなカルマモーメントプラグインをインストール:
フレームワーク:[ 'jqueryの-3.2.1'、 'ジャスミン'、 'browserify'、 'モーメント2.9.0']、
プラグイン:[ 'カルマ-jqueryの' 「karma- browserify '、 'カルマ-瞬間'、 'カルマ・ジャスミン'、 'カルマ - クロム - ランチャー'、 「カルマ・ジャスミン-HTML-記者 ]
答えをありがとう、私はそれを認識していませんでした。 – Lucky500