TypeError: Cannot read property 'setUp' of undefined
See original GitHub issueSo I’m looking at Caolan Mcmahon’s Tutorial Adding the following code causes the title error
console.log = function (str) {
test.equal(str, 'doubled: 24');
};
The problem line is test.equal(str, 'doubled: 24');
.
Issue Analytics
- State:
- Created 10 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'setup' of undefined (line:289)
Hi everybody, I have been playing with uibuilder and really enjoying it. Developing it locally, everything has went smoothly but I have been...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >What is "TypeError: Cannot read property 'state' of undefined"?
The error message says that you don't have the state property on an undefined object. To decode this, we have to understand the...
Read more >javascript - TypeError: Cannot read properties of undefined ...
In some case, your args[0] is undefined that's why it is throwing the error. Use of ? will only check for toLowerCase() when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone else who finds this, ‘when callbacks are hit multiple times or in odd ways’ probably means; if you have multiple callbacks that invoke test.done() asynchronously.
For example:
Will sometimes trigger it, sometimes not depending on race conditions; you can resolve by ensuring that all the promises are resolved and then calling test.done(), not calling it multiple times.
(It would be very useful is test.done() error’d with a meaningful error message if it was called outside of a test scope)
I saw this issue today on a set of tests that had previously been working. In the event that this helps someone else, it was an issue with a badly formed callback. The error message is misleading. What I had done was something like this:
function A(callback){ // code… if (someCondition){ callback(); //<- problem here, should have been return callback() } callback(); }
Then in the test:
exports.myTest(test){ A(function(){ test.done() }) }
This issue is that test.done() was called twice due to that upstream callback being a problem. That second call to test.done() was causing nodeunit to look for a test that doesn’t exist and failing on the call to “group”. But it’s not clear from the error what is happening. I found it by using mocha to run the same test and it correctly reported “done() called more than once” which is what I think nodeunit needs to do.
t.