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
66031b03
...
66031b0305e5435d8e960037e2aba4ad37f416b4
authored
2013-03-07 00:54:07 +0100
by
Julien Muetton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add `casper.thenSkip()`, `casper.thenSkipIf()`...
... and `casper.thenSkipUnless()`
1 parent
6dd97c9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
0 deletions
modules/casper.js
tests/suites/casper/skip.js
modules/casper.js
View file @
66031b0
...
...
@@ -1614,6 +1614,55 @@ Casper.prototype.thenOpen = function thenOpen(location, settings, then) {
};
/**
* Skip `nb` tests.
*
* @param Integer nb number of tests to skip
* @param String message message to display
*/
Casper
.
prototype
.
thenSkip
=
function
(
nb
,
message
)
{
return
this
.
then
(
function
()
{
this
.
test
.
skip
(
nb
,
message
);
});
};
/**
* Skip `nb` tests if condition is true.
*
* @param Mixed condition number of tests to skip
* @param Integer nb number of tests to skip
* @param String message message to display
*/
Casper
.
prototype
.
thenSkipIf
=
function
(
condition
,
nb
,
message
)
{
return
this
.
then
(
function
()
{
if
(
utils
.
isFunction
(
condition
))
{
condition
=
condition
();
}
if
(
utils
.
isTruthy
(
condition
))
{
this
.
test
.
skip
(
nb
,
message
);
}
});
};
/**
* Skip `nb` tests if condition is true.
*
* @param Mixed condition number of tests to skip
* @param Integer nb number of tests to skip
* @param String message message to display
*/
Casper
.
prototype
.
thenSkipUnless
=
function
(
condition
,
nb
,
message
)
{
return
this
.
then
(
function
()
{
if
(
utils
.
isFunction
(
condition
))
{
condition
=
condition
();
}
if
(
utils
.
isFalsy
(
condition
))
{
this
.
test
.
skip
(
nb
,
message
);
}
});
};
/**
* Adds a new navigation step for opening and evaluate an expression
* against the DOM retrieved from the provided location.
*
...
...
tests/suites/casper/skip.js
View file @
66031b0
...
...
@@ -61,3 +61,78 @@ casper.test.begin('Skip does not polluate next suite', 1, function(test) {
});
});
casper
.
test
.
begin
(
'Casper.thenSkip'
,
2
,
function
(
test
)
{
casper
.
thenSkip
(
1
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenSkipIf'
,
5
,
function
(
test
)
{
casper
.
thenSkipIf
(
true
,
1
,
"Skip if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipIf
(
function
()
{
return
true
;
},
1
,
"Skip if with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipIf
(
function
()
{
return
false
;
},
1
,
"Do not skip if with function"
).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
casper
.
test
.
begin
(
'Casper.thenSkipUnless'
,
5
,
function
(
test
)
{
casper
.
thenSkipUnless
(
false
,
1
,
"Skip unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipUnless
(
function
()
{
return
false
;
},
1
,
"Skip unless with function"
).
then
(
function
()
{
test
.
fail
(
"This test should be skipped."
);
}).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
}).
thenSkipUnless
(
function
()
{
return
true
;
},
1
,
"Do not skip unless with function"
).
then
(
function
()
{
test
.
pass
(
"This test should be executed."
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment