I'm trying to use your project as an example to add unit testing to my own VSS SDK web extension - this is the closest I've come to getting unit tests working, after many days of searching.
I was able to download and run your tests, but when I try to apply this to my own project ( a fork of Microsoft/vsts-team-calendar), I get an error when I run tsc ./tests/TestSpec.ts
:
I'm wondering if you can give any hints on how to handle this? Do you know of any projects successfully testing when VSS SDK components are imported?
I'll include some of my code/config as reference in the hope that you might have a minute to help:
TestSpec.ts:
import jasmine = require("jasmine");
import * as DateUtils from "../src/Calendar/Utils/TestDate";
describe('JavaScript addition operator', function() {
it ('adds two numbers together', function(){
expect(1+2).toEqual(3);
});
});
describe('inputStringToIsoString', () => {
it('Converts input date string to ISO string', () => {
expect(DateUtils.getDatesInRange(
new Date(2018, 4, 25),
new Date(2018,4,26)
))
.toEqual([
new Date(2018, 4, 25),
new Date(2018,4,26)
]);
});
});
import Utils_Date = require("VSS/Utils/Date");
export function getDatesInRange(startDate:Date, endDate: Date): Date[] {
const dates = [];
let current: Date = startDate;
while (current.getTime() <= endDate.getTime()) {
dates.push(new Date(<any>current));
current = Utils_Date.addDays(current, 1);
}
return dates;
}