0

I haven't used Mocha before, so I am a real novice when it comes to testing. However, I wanted to know if it's possible to test a function expression inside of a function expression? I know there are other posts on how you cannot access function expressions inside function declarations and so on.

So, is it possible to access function expressions inside function expressions and test with Mocha? For example, I have the following code:

var masterFunction = function() {

       var siGogglin = functionDeclaration(putSomethingHere);

       function functionDeclaration(code) {
           var yoyo = [];

           //some stuff I don't want you to see 

           return yoyo;
       };
};

Is it possible to test the function functionDeclaration from the variable siGogglin within masterFunction? If so, could you give me an example of how it could be done?

Thanks.

1 Answer 1

1

My answer would be no because you essentially created a private function within masterFunction which should have no access outside of the masterFunction scope unless you add a getter method to the prototype.

Sign up to request clarification or add additional context in comments.

1 Comment

That's what I thought but I wanted to ask anyway. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.