Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
41710652
...
41710652a88cb91db35ff82209f891fe77b2cb67
authored
2012-12-31 11:13:46 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
introduced TimedOutError for timed out tests
1 parent
1932d880
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
29 deletions
modules/tester.js
modules/tester.js
View file @
4171065
...
...
@@ -45,6 +45,15 @@ function AssertionError(msg, result) {
AssertionError
.
prototype
=
new
Error
();
exports
.
AssertionError
=
AssertionError
;
function
TimedOutError
(
msg
)
{
"use strict"
;
Error
.
call
(
this
);
this
.
message
=
msg
;
this
.
name
=
'TimedOutError'
;
}
TimedOutError
.
prototype
=
new
Error
();
exports
.
TimedOutError
=
TimedOutError
;
/**
* Creates a tester instance.
*
...
...
@@ -101,8 +110,6 @@ var Tester = function Tester(casper, options) {
this
.
started
=
false
;
this
.
suiteResults
=
new
TestSuiteResult
();
this
.
configure
();
this
.
on
(
'success'
,
function
onSuccess
(
success
)
{
var
timeElapsed
=
new
Date
()
-
this
.
currentTestStartTime
;
this
.
currentSuite
.
addSuccess
(
success
,
timeElapsed
-
this
.
lastAssertTime
);
...
...
@@ -167,6 +174,28 @@ var Tester = function Tester(casper, options) {
self
.
currentSuite
.
addWarning
(
warning
);
}
});
// Do not hook casper if we're not testing
if
(
!
phantom
.
casperTest
)
{
return
;
}
// onRunComplete
this
.
casper
.
options
.
onRunComplete
=
function
test_onRunComplete
(
casper
)
{
};
// specific timeout callbacks
this
.
casper
.
options
.
onStepTimeout
=
function
test_onStepTimeout
(
timeout
,
step
)
{
throw
new
TimedOutError
(
f
(
"Step timeout occured at step %s (%dms)"
,
step
,
timeout
));
};
this
.
casper
.
options
.
onTimeout
=
function
test_onTimeout
(
timeout
)
{
throw
new
TimedOutError
(
f
(
"Timeout occured (%dms)"
,
timeout
));
};
this
.
casper
.
options
.
onWaitTimeout
=
function
test_onWaitTimeout
(
timeout
)
{
throw
new
TimedOutError
(
f
(
"Wait timeout occured (%dms)"
,
timeout
));
};
};
// Tester class is an EventEmitter
...
...
@@ -800,33 +829,6 @@ Tester.prototype.comment = function comment(message) {
};
/**
* Configure casper callbacks for testing purpose.
*
*/
Tester
.
prototype
.
configure
=
function
configure
()
{
"use strict"
;
var
tester
=
this
;
// Do not hook casper if we're not testing
if
(
!
phantom
.
casperTest
)
{
return
;
}
// specific timeout callbacks
this
.
casper
.
options
.
onStepTimeout
=
function
test_onStepTimeout
(
timeout
,
step
)
{
tester
.
fail
(
f
(
"Step timeout occured at step %s (%dms)"
,
step
,
timeout
));
};
this
.
casper
.
options
.
onTimeout
=
function
test_onTimeout
(
timeout
)
{
tester
.
fail
(
f
(
"Timeout occured (%dms)"
,
timeout
));
};
this
.
casper
.
options
.
onWaitTimeout
=
function
test_onWaitTimeout
(
timeout
)
{
tester
.
fail
(
f
(
"Wait timeout occured (%dms)"
,
timeout
));
};
};
/**
* Declares the current test suite done.
*
* @param Number planned Number of planned tests
...
...
Please
register
or
sign in
to post a comment