Reputation: 139
I am using jasmine to test my javascript functions. My describe function & it functions are in different files.
I am trying to pass parameter to describe function but i am getting an error.
describe("Test file-utils funtions",fileUtilsFunc("abc"))
// Getting Error: describe expects a function argument; received [object Undefined]
It is not allowing to pass "abc" parameter.
Upvotes: 0
Views: 840
Reputation: 2611
Describe expects two arguments:
In your code you are passing the former correctly, but the latter is not a name of a function, but a function call which will be evaluated. Unless your fileUtilsFunc function returns another function it won't work. fileUtilsFunc returning undefined appears to be a problem with your code.
You should try passing function with test cases:
describe("Test file-utils funtions",fileUtilsFunc)
function fileUtilsFunc() {
it("Test case name", function() {/*test case code*/});
}
Or function which returns function with test cases:
describe("Test file-utils funtions",fileUtilsFunc())
function fileUtilsFunc() {
return function() {
it("Test case name", function() {/*test case code*/});
}
}
Notice difference between fileUtilsFunc in first example and fileUtilsFunc() in second example.
Upvotes: 2