-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
15,468 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="chutzpahRunner.js" /> | ||
|
||
(async function () { | ||
|
||
const functions = require('../jasmineFunctionsV3.js'); | ||
const chutzpahRunner = require('./chutzpahRunner.js'); | ||
|
||
try { | ||
await chutzpahRunner.runner( | ||
functions.onInitialized, | ||
functions.onPageLoaded, | ||
functions.isJasmineLoaded, | ||
functions.onJasmineLoaded, | ||
functions.isTestingDone); | ||
|
||
} catch (e) { | ||
throw new Error("Failed to run jasmineRunnerV3.js: " + e); | ||
} | ||
})().catch(e => { | ||
console.error(e); | ||
process.exit(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="chutzpahRunner.js" /> | ||
|
||
(async function () { | ||
|
||
const functions = require('../jasmineFunctionsV3.js'); | ||
const chutzpahRunner = require('./chutzpahRunner.js'); | ||
|
||
try { | ||
await chutzpahRunner.runner( | ||
functions.onInitialized, | ||
functions.onPageLoaded, | ||
functions.isJasmineLoaded, | ||
functions.onJasmineLoaded, | ||
functions.isTestingDone); | ||
|
||
} catch (e) { | ||
throw new Error("Failed to run jasmineRunnerV3.js: " + e); | ||
} | ||
})().catch(e => { | ||
console.error(e); | ||
process.exit(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
var module = module || {}; | ||
module.exports = module.exports || {}; | ||
|
||
function onInitialized() { | ||
console.log("!!_!! onInitialized Jasmine - v3"); | ||
} | ||
|
||
function isTestingDone() { | ||
console.log("!!_!! isTestingDone"); | ||
return window.chutzpah.isTestingFinished === true; | ||
} | ||
|
||
function isJasmineLoaded() { | ||
console.log("!!_!! isJasmineLoaded"); | ||
return !!window.jasmine && !!window.jasmine.getEnv; | ||
} | ||
|
||
function onJasmineLoaded() { | ||
|
||
console.log("!!_!! onJasmineLoaded"); | ||
|
||
function log(obj) { | ||
console.log(JSON.stringify(obj)); | ||
} | ||
|
||
|
||
var activeTestCase = null, | ||
fileStartTime = null, | ||
testStartTime = null, | ||
suites = []; | ||
|
||
window.chutzpah.isTestingFinished = false; | ||
window.chutzpah.testCases = []; | ||
|
||
function logCoverage() { | ||
if (window._Chutzpah_covobj_name && window[window._Chutzpah_covobj_name]) { | ||
log({ type: "CoverageObject", object: JSON.stringify(window[window._Chutzpah_covobj_name]) }); | ||
} | ||
} | ||
|
||
function recordStackTrace(stack) { | ||
if (stack) { | ||
// Truncate stack to 5 deep. | ||
stack = stack.split('\n').slice(1, 6).join('\n'); | ||
} | ||
return stack; | ||
} | ||
|
||
|
||
function ChutzpahJasmineReporter(options) { | ||
|
||
var passedCount = 0; | ||
var failedCount = 0; | ||
var skippedCount = 0; | ||
|
||
this.jasmineStarted = function () { | ||
|
||
fileStartTime = new Date().getTime(); | ||
|
||
// Testing began | ||
log({ type: "FileStart" }); | ||
}; | ||
|
||
|
||
this.jasmineDone = function () { | ||
var timetaken = new Date().getTime() - fileStartTime; | ||
logCoverage(); | ||
log({ type: "FileDone", timetaken: timetaken, passed: passedCount, failed: failedCount }); | ||
window.chutzpah.isTestingFinished = true; | ||
}; | ||
|
||
|
||
this.suiteStarted = function (result) { | ||
suites.push(result); | ||
}; | ||
|
||
this.suiteDone = function (result) { | ||
suites.pop(); | ||
}; | ||
|
||
this.specStarted = function (result) { | ||
var currentSuiteName = suites.length > 0 | ||
? suites[suites.length - 1].fullName | ||
: null; | ||
|
||
testStartTime = new Date().getTime(); | ||
var suiteName = currentSuiteName; | ||
var specName = result.description; | ||
var newTestCase = { moduleName: suiteName, testName: specName, testResults: [] }; | ||
window.chutzpah.testCases.push(newTestCase); | ||
activeTestCase = newTestCase; | ||
log({ type: "TestStart", testCase: activeTestCase }); | ||
}; | ||
|
||
this.specDone = function (result) { | ||
if (result.status === "disabled") { | ||
return; | ||
} | ||
|
||
if (result.status === "failed") { | ||
failedCount++; | ||
} | ||
else if (result.status === "pending") { | ||
skippedCount++; | ||
activeTestCase.skipped = true; | ||
} | ||
else { | ||
passedCount++; | ||
} | ||
|
||
var timetaken = new Date().getTime() - testStartTime; | ||
activeTestCase.timetaken = timetaken; | ||
|
||
for (var i = 0; i < result.failedExpectations.length; i++) { | ||
var expectation = result.failedExpectations[i]; | ||
|
||
var testResult = {}; | ||
testResult.passed = false; | ||
testResult.message = expectation.message; | ||
testResult.stackTrace = recordStackTrace(expectation.stack); | ||
activeTestCase.testResults.push(testResult); | ||
|
||
} | ||
|
||
// Log test case when done. This will get picked up by phantom and streamed to chutzpah. | ||
log({ type: "TestDone", testCase: activeTestCase }); | ||
|
||
|
||
}; | ||
|
||
} | ||
|
||
if (window.chutzpah.testMode) { | ||
jasmine.getEnv().addReporter(new ChutzpahJasmineReporter()); | ||
} | ||
|
||
if (window.chutzpah.testMode === 'discovery') { | ||
// If discovery mode overwrite execute to not run the test | ||
jasmine.getEnv().beforeAll = function () { }; | ||
jasmine.getEnv().afterAll = function () { }; | ||
jasmine.Spec.prototype.execute = function (onComplete) { | ||
this.onStart(this); | ||
this.resultCallback(this.result); | ||
if (onComplete) | ||
onComplete(); | ||
}; | ||
} | ||
|
||
} | ||
|
||
function onPageLoaded() { | ||
console.log("!!_!! onPageLoaded"); | ||
|
||
if (!window.chutzpah.usingModuleLoader && window.chutzpah.autoStart !== false) { | ||
(window.chutzpah.start || window.initializeJasmine)(); | ||
} | ||
} | ||
|
||
module.exports.onInitialized = onInitialized; | ||
module.exports.isTestingDone = isTestingDone; | ||
module.exports.isJasmineLoaded = isJasmineLoaded; | ||
module.exports.onJasmineLoaded = onJasmineLoaded; | ||
module.exports.onPageLoaded = onPageLoaded; |
Oops, something went wrong.