No stack on assertion error in PhantomJS
See original GitHub issueSteps to reproduce:
-
Install PhantomJS
npm install -g phantomjs-prebuilt
-
Download the chai browser build into a dir, save it as
chai.js
. -
Create
test.html
in the same dir with these contents:<script src="chai.js"></script> <script> try { chai.expect(1).to.equal(2); } catch (error) { console.log('Stack on chai assertion error:', error.stack); } try { throw new Error('regular'); } catch (error) { console.log('Stack on regular error:', error.stack); } window.close(); </script>
-
Create
test.js
in the same dir with these contents:var page = require('webpage').create(); page.onConsoleMessage = console.log.bind(console); page.onClosing = phantom.exit; page.open('test.html');
-
Execute on the command line in that dir:
phantomjs test.js
Expected result:
- Both the assertion error and the regular error have stack information.
Actual result:
- The regular error has stack information, but the assertion error’s stack is undefined.
In Chrome, however, both errors have a proper stack.
Tested with chai 3.5.0 and PhantomJS 2.1.1
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Error message when using PhantomJS, breaks at random ...
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on...
Read more >Uncaught AssertionError: html-pdf: Failed to load PhantomJS ...
Unfortunately yes, it seems you will have to install phantomJS manually sometimes on a mac system. This occurs in legacy/fallback mode, and the ......
Read more >Release History - Chai Assertion Library
The operator is a property of the AssertionError thrown when assertions fail. This flag indicates what kind of comparison was made.
Read more >onError - PhantomJS
onError. Introduced: PhantomJS 1.5. This callback is invoked when there is a JavaScript execution error not caught by a page.onError handler.
Read more >Practical Ways to Write Better JavaScript - Stack Overflow Blog
no good console.log(foo("two")); // invalid TS code ... against common errors/bugs, which is a blessing for a lawless language like JS.
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
Soon @eekboom, soon.
@xcafebabe Yup you’re right, I forgot that we don’t currently regenerate the
chai.js
file on every commit to the master branch. On the plus side, we’ll be releasing an alpha release of Chai 4.0 very soon that will have this change. And going forward we plan on releasing new versions more rapidly using semantic release.An interim solution is to clone the chai repo and run
npm install && npm test
and it will regeneratechai.js
with the patch included.