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
c24f3e2e
...
c24f3e2e0002c746b8b07b7f2029bc52222d2aa4
authored
2014-02-17 16:01:27 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed #821 - test.assertRaises always PASS
1 parent
69728f9b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
modules/tester.js
tests/suites/tester/assert.js
modules/tester.js
View file @
c24f3e2
...
...
@@ -688,20 +688,23 @@ Tester.prototype.assertRaises =
Tester
.
prototype
.
assertRaise
=
Tester
.
prototype
.
assertThrows
=
function
assertRaises
(
fn
,
args
,
message
)
{
"use strict"
;
var
context
=
{
var
thrown
=
false
,
error
=
undefined
,
context
=
{
type
:
"assertRaises"
,
standard
:
"Function raises an error"
};
try
{
fn
.
apply
(
null
,
args
);
this
.
assert
(
false
,
message
,
context
);
}
catch
(
error
)
{
this
.
assert
(
true
,
message
,
utils
.
mergeObjects
(
context
,
{
}
catch
(
err
)
{
thrown
=
true
;
error
=
err
;
}
this
.
assert
(
thrown
,
message
,
utils
.
mergeObjects
(
context
,
{
values
:
{
error
:
error
}
}));
}
};
/**
...
...
tests/suites/tester/assert.js
View file @
c24f3e2
...
...
@@ -48,12 +48,12 @@ casper.test.begin('Common assertions tests', 47, function(test) {
test
.
assertRaises
(
function
()
{
throw
new
Error
(
'plop'
);
},
[],
'Tester.assertRaises() works as expected'
);
t
est
.
assertRaise
(
function
()
{
t
hrow
new
Error
(
'plop'
);
},
[],
'Tester.assertRaise() works as expected [alias]'
);
test
.
assertThrows
(
function
(
)
{
t
hrow
new
Error
(
'plop'
);
}
,
[],
'Tester.assertThrows() works as expected [alias]'
);
t
ry
{
t
est
.
assertRaises
(
function
()
{},
[]
);
test
.
fail
(
"Tester.assertRaises() doesn't pass when no error is thrown"
);
}
catch
(
err
)
{
t
est
.
pass
(
"Tester.assertRaises() doesn't pass when no error is thrown"
);
}
test
.
assertResourceExists
(
/index
\.
html/
,
'Tester.assertResourceExists() works as expected'
);
test
.
assertResourceExist
(
/index
\.
html/
,
'Tester.assertResourceExist() works as expected [alias]'
);
test
.
assertTitle
(
'CasperJS test index'
,
'Tester.assertTitle() works as expected'
);
...
...
Please
register
or
sign in
to post a comment