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
ca0604c8
...
ca0604c8b5da339ccdda12142ac0cdf29cdd1e2e
authored
2013-03-06 14:40:22 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed #404 - --fail-fast option was broken
1 parent
dc87cc13
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
26 deletions
modules/tester.js
tests/suites/utils.js
modules/tester.js
View file @
ca0604c
...
...
@@ -144,16 +144,7 @@ var Tester = function Tester(casper, options) {
// casper events
this
.
casper
.
on
(
'error'
,
function
onCasperError
(
msg
,
backtrace
)
{
if
(
/^AssertionError/
.
test
(
msg
))
{
return
;
}
this
.
test
.
fail
(
msg
,
{
type
:
"error"
,
doThrow
:
false
,
values
:
{
stack
:
backtrace
}
});
self
.
processPhantomError
(
msg
,
backtrace
);
});
this
.
casper
.
on
(
'waitFor.timeout'
,
function
onWaitForTimeout
(
timeout
)
{
...
...
@@ -165,13 +156,11 @@ var Tester = function Tester(casper, options) {
self
.
processError
(
error
);
return
self
.
done
();
}
if
(
error
.
indexOf
(
'AssertionError'
)
===
0
)
{
if
(
utils
.
isString
(
error
)
&&
error
.
indexOf
(
'AssertionError'
)
===
0
)
{
return
;
}
if
(
error
===
self
.
SKIP_MESSAGE
)
{
casper
.
warn
(
f
(
'--fail-fast: aborted remaining tests in "%s"'
,
self
.
currentTestFile
));
self
.
aborted
=
true
;
return
self
.
done
();
return
self
.
abort
(
'--fail-fast: aborted all remaining tests'
);
}
var
line
=
0
;
try
{
...
...
@@ -216,6 +205,18 @@ utils.inherits(Tester, events.EventEmitter);
exports
.
Tester
=
Tester
;
/**
* Aborts current test suite.
*
* @param {String} message Warning message (optional)
*/
Tester
.
prototype
.
abort
=
function
abort
(
message
)
{
"use strict"
;
this
.
aborted
=
true
;
this
.
casper
.
warn
(
message
||
'test suite aborted'
);
this
.
done
();
};
/**
* Asserts that a condition strictly resolves to true. Also returns an
* "assertion object" containing useful informations about the test case
* results.
...
...
@@ -1091,16 +1092,6 @@ Tester.prototype.pass = function pass(message) {
});
};
Tester
.
prototype
.
prepare
=
function
prepare
(
config
)
{
"use strict"
;
if
(
!
utils
.
isObject
(
config
))
{
throw
new
CasperError
(
'prepare() needs a config object'
);
}
if
(
'setUp'
in
config
)
{
}
};
/**
* Processes an assertion error.
*
...
...
@@ -1108,7 +1099,7 @@ Tester.prototype.prepare = function prepare(config) {
*/
Tester
.
prototype
.
processAssertionError
=
function
(
error
)
{
"use strict"
;
var
result
=
error
&&
error
.
result
,
var
result
=
error
&&
error
.
result
||
{}
,
testFile
=
this
.
currentTestFile
,
stackEntry
;
try
{
...
...
@@ -1175,6 +1166,31 @@ Tester.prototype.processError = function processError(error) {
};
/**
* Processes a PhantomJS error, which is an error message and a backtrace.
*
* @param {String} message
* @param {Array} backtrace
*/
Tester
.
prototype
.
processPhantomError
=
function
processPhantomError
(
msg
,
backtrace
)
{
"use strict"
;
if
(
/^AssertionError/
.
test
(
msg
))
{
this
.
casper
.
warn
(
'looks you did not use begin() which is mandatory since 1.1'
);
}
if
(
msg
===
this
.
SKIP_MESSAGE
)
{
return
this
.
abort
(
'--fail-fast: aborted all remaining tests'
);
}
this
.
fail
(
msg
,
{
type
:
"error"
,
doThrow
:
false
,
values
:
{
error
:
msg
,
stack
:
backtrace
}
});
this
.
done
();
};
/**
* Renders a detailed report for each failed test.
*
*/
...
...
tests/suites/utils.js
View file @
ca0604c
/*global casper*/
/*jshint strict:false maxstatements:99*/
/*jshint strict:false
,
maxstatements:99*/
var
utils
=
require
(
'utils'
),
t
=
casper
.
test
,
x
=
require
(
'casper'
).
selectXPath
;
...
...
Please
register
or
sign in
to post a comment