Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -21,5 +21,7 @@ "use strict"; | ||
testFixtureKeys.forEach(function (testFixtureKey) { | ||
var testFixture = _this._loadTestFixture(Test[testFixtureKey], testFixtureKey); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
if (typeof Test[testFixtureKey] === "function") { | ||
var testFixture = _this._loadTestFixture(Test[testFixtureKey], testFixtureKey); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
} | ||
} | ||
@@ -26,0 +28,0 @@ }); |
@@ -9,28 +9,30 @@ import { ITestFixture, ITest, ITestCase } from "./_interfaces"; | ||
loadTestFixture(filePath: string): Array<ITestFixture> { | ||
let Test = this._fileRequirer.require(filePath); | ||
let testFixtureKeys = Object.keys(Test); | ||
let testFixtures: Array<ITestFixture> = []; | ||
loadTestFixture(filePath: string): Array<ITestFixture> { | ||
let Test = this._fileRequirer.require(filePath); | ||
let testFixtureKeys = Object.keys(Test); | ||
let testFixtures: Array<ITestFixture> = []; | ||
// if the default export is class constructor | ||
if (typeof Test === "function") { | ||
let testFixture = this._loadTestFixture(Test, Test.name); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
// if the default export is class constructor | ||
if (typeof Test === "function") { | ||
let testFixture = this._loadTestFixture(Test, Test.name); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
} | ||
} | ||
} | ||
// otherwise there are multiple exports and we must handle all of them | ||
else { | ||
testFixtureKeys.forEach(testFixtureKey => { | ||
let testFixture = this._loadTestFixture(Test[testFixtureKey], testFixtureKey); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
} | ||
}); | ||
} | ||
// otherwise there are multiple exports and we must handle all of them | ||
else { | ||
testFixtureKeys.forEach(testFixtureKey => { | ||
if (typeof Test[testFixtureKey] === "function") { | ||
let testFixture = this._loadTestFixture(Test[testFixtureKey], testFixtureKey); | ||
if (testFixture !== null) { | ||
testFixtures.push(testFixture); | ||
} | ||
} | ||
}); | ||
} | ||
return testFixtures; | ||
return testFixtures; | ||
} | ||
private _loadTestFixture(testFixtureConstructor: any, name: string): ITestFixture { | ||
private _loadTestFixture(testFixtureConstructor: any, name: string): ITestFixture { | ||
let testFixture = new TestFixture(name); | ||
@@ -41,6 +43,6 @@ | ||
if (Reflect.getMetadata(METADATA_KEYS.IGNORE, testFixtureConstructor)) { | ||
// fixture should be ignored | ||
testFixture.ignored = true; | ||
// fixture should be ignored | ||
testFixture.ignored = true; | ||
testFixture.ignoreReason = Reflect.getMetadata(METADATA_KEYS.IGNORE_REASON, testFixtureConstructor); | ||
testFixture.ignoreReason = Reflect.getMetadata(METADATA_KEYS.IGNORE_REASON, testFixtureConstructor); | ||
} | ||
@@ -57,8 +59,8 @@ | ||
if (Reflect.getMetadata(METADATA_KEYS.FOCUS, testFixtureConstructor)) { | ||
testFixture.focussed = true; | ||
testFixture.focussed = true; | ||
} | ||
if (tests === undefined) { | ||
// no tests on the fixture | ||
return null; | ||
// no tests on the fixture | ||
return null; | ||
} | ||
@@ -68,40 +70,40 @@ | ||
// the test is ignored if the fixture is, or if it's specifically ignored | ||
test.ignored = false; | ||
if (testFixture.ignored || Reflect.getMetadata(METADATA_KEYS.IGNORE, testFixture.fixture, test.key)) { | ||
test.ignored = true; | ||
// the test is ignored if the fixture is, or if it's specifically ignored | ||
test.ignored = false; | ||
if (testFixture.ignored || Reflect.getMetadata(METADATA_KEYS.IGNORE, testFixture.fixture, test.key)) { | ||
test.ignored = true; | ||
// individual test ignore reasons take precedence over test fixture ignore reasons | ||
test.ignoreReason = Reflect.getMetadata(METADATA_KEYS.IGNORE_REASON, testFixture.fixture, test.key) || testFixture.ignoreReason; | ||
} | ||
// individual test ignore reasons take precedence over test fixture ignore reasons | ||
test.ignoreReason = Reflect.getMetadata(METADATA_KEYS.IGNORE_REASON, testFixture.fixture, test.key) || testFixture.ignoreReason; | ||
} | ||
test.focussed = false; | ||
test.focussed = false; | ||
if (Reflect.getMetadata(METADATA_KEYS.FOCUS, testFixture.fixture, test.key)) { | ||
test.focussed = true; | ||
} | ||
if (Reflect.getMetadata(METADATA_KEYS.FOCUS, testFixture.fixture, test.key)) { | ||
test.focussed = true; | ||
} | ||
test.timeout = Reflect.getMetadata(METADATA_KEYS.TIMEOUT, testFixture.fixture, test.key) || null; | ||
test.timeout = Reflect.getMetadata(METADATA_KEYS.TIMEOUT, testFixture.fixture, test.key) || null; | ||
testFixture.addTest(test); | ||
testFixture.addTest(test); | ||
if (!test.description) { | ||
test.description = test.key; | ||
} | ||
if (!test.description) { | ||
test.description = test.key; | ||
} | ||
let testCases = Reflect.getMetadata(METADATA_KEYS.TEST_CASES, testFixture.fixture, test.key); | ||
test.testCases = []; | ||
let testCases = Reflect.getMetadata(METADATA_KEYS.TEST_CASES, testFixture.fixture, test.key); | ||
test.testCases = []; | ||
if (!testCases) { | ||
test.testCases.push({ arguments: [] }); | ||
} | ||
else { | ||
testCases.forEach((testCase: ITestCase) => { | ||
test.testCases.push(testCase); | ||
}); | ||
} | ||
if (!testCases) { | ||
test.testCases.push({ arguments: [] }); | ||
} | ||
else { | ||
testCases.forEach((testCase: ITestCase) => { | ||
test.testCases.push(testCase); | ||
}); | ||
} | ||
}); | ||
return testFixture; | ||
} | ||
} | ||
} |
{ | ||
"name": "alsatian", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "TypeScript testing framework with test cases", | ||
@@ -5,0 +5,0 @@ "author": "James Richford <=> (=)", |
Sorry, the diff of this file is not supported yet
593565
4618