question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No stack on assertion error in PhantomJS

See original GitHub issue

Steps to reproduce:

  1. Install PhantomJS

    npm install -g phantomjs-prebuilt
    
  2. Download the chai browser build into a dir, save it as chai.js.

  3. 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>
    
  4. 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');
    
  5. 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:closed
  • Created 8 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
keithamuscommented, Apr 11, 2016

Soon @eekboom, soon.

1reaction
meebercommented, Aug 15, 2016

@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 regenerate chai.js with the patch included.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found