Get line of error/assertionError in postman - javascript

So I m getting an assertion error in postman, and the error looks like this:
There was an error in evaluating the test script: AssertionError: expected undefined to be a string
But i have 300 assertions for this API, and is virtually impossible to idenftify what assertion actually failed, is there a way for me to make postman show the line number that raised the assertionFail?

There is a way to get the line number if you dig down into this:
How do you find out the caller function in JavaScript?
Wrap your asserts in a very large try catch. Then print out the stack in the catch.
Details
Append the catch at the bottom. Something like this:
try {
// 300 asserts here
}catch (e) {
console.log(e);
console.log(`e.stack = ${e.stack}`);
}
When PM hits the assert you will see something like:
{type: "Error", name: "TypeError", message: "Cannot read property 'json' of undefined"}
e.stack = TypeError: Cannot read property 'json' of undefined
at Object.eval (eval at exec (evalmachine.<anonymous>:58:1931768), <anonymous>:89:30)
at u.exec (evalmachine.<anonymous>:58:1931803)
at t.exports (evalmachine.<anonymous>:58:5743)
at Object.<anonymous> (evalmachine.<anonymous>:58:7440)
at evalmachine.<anonymous>:15:26
at Array.forEach (<anonymous>)
at Object.emit (evalmachine.<anonymous>:14:54)
at evalmachine.<anonymous>:51:24
at evalmachine.<anonymous>:5:21
at evalmachine.<anonymous>:6:18
The top of the stack tells you the line number (zero-based):
at Object.eval (eval at exec (evalmachine.:58:1931768), :89:30)
So in this case 89, is reported as 88 in the IDE.
BTW it appears that the 30 is actually the column number of the called method.
Additional entries give a longer trace, showing the lineage of the calls before the error occurred, which may be useful in some debugging cases.
Warning this will cause the first assert error to interrupt any further testing. So undo this change when you are done.

Related

Electron - Resize Window from renderer process

I am working on an Electron app and as part of the interface I want to increase the size of the window once something has happened (I have bound this to a button for now) so I can display additional data. I have attempted to do this with the following code that is activated on a onclick=resize():
require('./renderer.js');
let remote = require('electron').remote;
function resize() {
let win = remote.getCurrentWindow().setBounds({
height: 1000
});
}
However, I am getting the following error in the window/browser console:
Uncaught Error: Could not call remote function 'setBounds'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
Error: Could not call remote function 'setBounds'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
at callFunction (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter.<anonymous> (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents.<anonymous> (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at callFunction (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:257:11)
at EventEmitter.<anonymous> (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:357:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)
at WebContents.<anonymous> (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:256:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)
at metaToValue (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:234:13)
at Object.remoteMemberFunction (C:\Users\Thomas\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:118:18)
at resize (file:///D:/Documents/Development/Projects/ShortenMeURL/V1/index.html:41:45)
at HTMLButtonElement.onclick (file:///D:/Documents/Development/Projects/ShortenMeURL/V1/index.html:22:86)
Any suggestions on how I can fix this?
Definition of Rectangle object (which is the first argument of setBounds) is more strict than you expected. Since its properties don't have default values you have to define all of them.
For example:
remote.getCurrentWindow().setBounds({
x: 1621,
y: 611,
width: 10,
height: 1000
});
Also, if you want to adjust only size you can use setSize of BrowserWindow
Just use plain old javascript from the renderer, I would not add an unnecessary messaging between main and renderer process if it is just a resize ;)
window.resizeTo(1000,900);
If anyone's getting a similar error, make sure you provide integer values, for example 123, not 123,45. Math.round them to make sure.
I don't see a mention of this in the documentation sadly.

'Failed with: TypeError: Cannot call method 'replace' of undefined' when running Parse background job

Whenever I run my Parse background job, it fails and I get the error below:
Failed with: TypeError: Cannot call method 'replace' of undefined
at Object.b.Query._quote (Parse.js:3:14236)
at Object.b.Query.contains (Parse.js:3:14337)
at main.js:1488:40
This is the area causing the problem, line 1488 is the 2nd line:
var MCI_Results_Update_Query = new Parse.Query(MCI_Results);
MCI_Results_Update_Query.contains('searchTerm', searchTermList[i]);
MCI_Results_Update_Query.equalTo('parent', parentUser);
All I'm doing here is setting the parameters for a query, there's no replace method involved at all. What's causing it to state that as the error? I triple checked, and I'm almost positive this is the line it's referring to.

Strange Meteor Error: [Log] Exception from Deps recompute function: NotFoundError: DOM Exception 8

This is such a random error message? What are good troubleshooting tips to track where this is coming from?
SAFARI Console:
[Log] Exception from Deps recompute function: NotFoundError: DOM Exception 8 (meteor.js, line 741)
insertBefore#[native code]
_insertNodeWithHooks#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:349:24
_insert#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:318:36
attach#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:23
_insert#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:313:13
attach#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:23
_insert#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:313:13
attach#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:23
setMembers#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:438:18
doMaterialize#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:1877:32
nonreactive#http://10.0.0.9/packages/deps.js?02d2ad4c6472ce004db73ba12c99864ab9acb468:397:13
doRender#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:1868:23
http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:1813:20
withCurrentView#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:2046:16
viewAutorun#http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:1812:33
_compute#http://10.0.0.9/packages/deps.js?02d2ad4c6472ce004db73ba12c99864ab9acb468:229:36
_recompute#http://10.0.0.9/packages/deps.js?02d2ad4c6472ce004db73ba12c99864ab9acb468:243:22
flush#http://10.0.0.9/packages/deps.js?02d2ad4c6472ce004db73ba12c99864ab9acb468:337:24
Chrome Debug:
Exception from Deps recompute function: Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
at Error (native)
at Function.DOMRange._insertNodeWithHooks (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:349:12)
at Function.DOMRange._insert (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:318:16)
at DOMRange.attach (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:16)
at Function.DOMRange._insert (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:313:7)
at DOMRange.attach (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:16)
at Function.DOMRange._insert (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:313:7)
at DOMRange.attach (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:395:16)
at DOMRange.setMembers (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:438:12)
at doMaterialize (http://10.0.0.9/packages/blaze.js?cf9aea283fb9b9d61971a3b466bff429f9d66d7d:1877:22)
Based on the Chrome error, you have a jQuery insertBefore statement that’s referencing something invalid. Search your code for insertBefore and comment them out one at a time until you make the error message disappear. If you don’t have any insertBefores in your code, it’s being called by a plugin or something lower-level.
I don't know what is it, but after restarting meteor app, exception is gone.

Error with Ext.Msg in js-test-driver tests

In my js-test-driver tests, I'm having an error from simply calling
Ext.Msg.alert('Error', 'An error occurred while trying load parameters for action with id ' + actionId);
Error Message: Uncaught TypeError: Cannot read property 'insertBefore' of null
Note that Ext.Msg.rendered is true and that Ext.Msg.el.dom.parentNode is null if I stop execution just before the error.
This error does not happen if:
The real app is running, only during tests.
If I run a single test, only if I run multiple tests that end up calling Ext.Msg.alert
Stack trace
Ext.define.insertBefore (ext-all-debug.js:13281)
Ext.define.show (ext-all-debug.js:42064)
Ext.define.sync (ext-all-debug.js:82755)
Ext.define.syncShadow (ext-all-debug.js:33992)
Ext.define.onAfterFloatLayout (ext-all-debug.js:34002)
Ext.define.afterComponentLayout (ext-all-debug.js:34374)
Base.implement.callParent (ext-all-debug.js:4455)
Ext.define.afterComponentLayout (ext-all-debug.js:38639)
Ext.define.notifyOwner (ext-all-debug.js:38067)
Ext.define.callLayout (ext-all-debug.js:125114)
Ext.define.flushLayouts (ext-all-debug.js:125283)
Ext.define.runComplete (ext-all-debug.js:125769)
callOverrideParent (ext-all-debug.js:36)
Base.implement.callParent (ext-all-debug.js:4455)
Ext.override.runComplete (ext-all-debug.js:29905)
Ext.define.run (ext-all-debug.js:125750)
Ext.define.statics.flushLayouts (ext-all-debug.js:29913)
Ext.define.statics.updateLayout (ext-all-debug.js:29947)
Ext.define.updateLayout (ext-all-debug.js:31844)
Ext.define.onContentChange (ext-all-debug.js:36116)
Ext.define.updateLayout (ext-all-debug.js:31839)
Ext.define.onContentChange (ext-all-debug.js:36116)
Ext.define.updateLayout (ext-all-debug.js:31839)
Ext.define.setTitle (ext-all-debug.js:53058)
Ext.define.setTitle (ext-all-debug.js:55155)
Ext.define.reconfigure (ext-all-debug.js:90310)
Ext.define.show (ext-all-debug.js:90476)
Ext.define.alert (ext-all-debug.js:90600)
Ext.define.onInstanceRetrievalError (BaseWorkflowActionController.js:139)
(anonymous function) (ext-all-debug.js:2265)
Ext.apply.callback (ext-all-debug.js:7437)
Ext.define.Ext.apply.inheritableStatics.load (mock.js:38)
Ext.define.onDocumentClick (BaseWorkflowActionController.js:73)
(anonymous function) (VM6566:6)
Ext.apply.createListenerWrap.wrap (ext-all-debug.js:10786)
AsyncTestCase.test_unknown_error_displays_error_dialog (WorkflowSingleActionController.Test.js:87)
Any ideas of what could be going on? Or something to try?
This question was cross-posted to http://www.sencha.com/forum/showthread.php?288372-Error-calling-Ext.Msg.alert-from-js-test-driver-tests&p=1053744#post1053744
The problem is that js-test-driver runs the following code which removes any content from the DOM at the end of each test.
var testRunnerPlugin =
new jstestdriver.plugins.TestRunnerPlugin(Date, function() {
jstestdriver.log(jstestdriver.jQuery('body')[0].innerHTML);
jstestdriver.jQuery('body').children().remove();
jstestdriver.jQuery(document).unbind();
jstestdriver.jQuery(document).die();
}, runTestLoop);
Therefore, the global Ext.Msg which was rendered onto the body becomes orphaned and it fails when trying to sync the shadow.
The solution is not to use the global Ext.Msg, always instantiate a new Ext.message.MessageBox if you want your code to be testable in js-test-driver
Here's a test case that reproduces the exact same stack trace https://fiddle.sencha.com/#fiddle/7i1

Zombie.js with Behat and Mink

I've been having problem after problem with getting Behat to work with Zombie.js. The problem I've got now is actually within the Zombie.js module (before, the errors were in the link between the two).
The error looks like so.
[RuntimeException]
Server process has been terminated: (8) [
url.js:107
throw new TypeError("Parameter 'url' must be a string, not " + typeof url)
^
TypeError: Parameter 'url' must be a string, not undefined
at Url.parse (url.js:107:11)
at urlParse (url.js:101:5)
at Object.urlResolve [as resolve] (url.js:405:10)
at History._resolve (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:201:20)
at History._assign (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:209:18)
at /Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:326:30
at Browser.withOptions (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:105:14)
at Browser.visit (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:320:12)
at Socket.eval (eval at <anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:10), <anonymous>:2:9)
at Socket.<anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:5)
]
I've found that in history.coffee, the resolve function is trying to use an array element that doesn't exist.
// history.coffee
_resolve: (url)->
if url
return URL.resolve(#_stack[#_index]?.url, url)
else # Yes, this could happen
return #_stack[#_index]?.url
That reference to #_stack[#_index] resolves to undefined, which is then being passed into URL.resolve, which is then causing the error.
Any idea why this would happen?
Update
I've noticed that #_stack is empty, and #_index is -1. This shouldn't be possible, right?
The zombie driver breaks with node version 0.8.24 (0.8.23 works ok). I believe this is due to the change:
2013.06.04, Version 0.8.24 (maintenance), c1a1ab067721ea17ef7b05ec5c68b01321017f05
* url: Properly parse certain oddly formed urls (isaacs)
A similar change (made on the same day) appears to have been made in 0.10.10 (although I've not studied the commits directly).
2013.06.04, Version 0.10.10 (Stable), 25e51c396aa23018603baae2b1d9390f5d9db496
* url: Properly parse certain oddly formed urls (isaacs)
I would recommend reverting to 0.8.23 or 0.10.9 in order to get this working. If you're not already using it I recommend nvm to manage your node installations.
Same issue when trying to simulate a $nodeElement->mouseOver() with Mink/Behat/Symfony2.1
TypeError: Parameter 'url' must be a string, not object
at Url.parse (url.js:107:11)
at urlParse (url.js:101:5)
at Object.urlResolve [as resolve] (url.js:405:10)
at Object.iframe.setAttribute (/usr/lib/node_modules/zombie/lib/zombie/jsdom_patches.js:164:43)
at attrCopy (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:331:14)
at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:636:18)
at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:706:37)
at Function.jQuery.extend.clone (/js/2225e47_jquery-1.8.2_2.js:6222:17)
at Function.jQuery.extend.parseHTML (/js/2225e47_jquery-1.8.2_2.js:501:31)
at jQuery.fn.jQuery.init (/js/2225e47_jquery-1.8.2_2.js:131:24)
at jQuery (/js/2225e47_jquery-1.8.2_2.js:44:10)
in /js/45a7194_jquery.jqModal_9.js
Node version is v0.10.15. Still digging for answers.

Categories

Resources