Coder Social home page Coder Social logo

should not working in browser about chai HOT 10 CLOSED

chaijs avatar chaijs commented on May 20, 2024
should not working in browser

from chai.

Comments (10)

jgallen23 avatar jgallen23 commented on May 20, 2024

this is in Firefox 9.0.1

from chai.

logicalparadox avatar logicalparadox commented on May 20, 2024

The should interface does it's thing by extending Object.prototype on L22. Unfortunately, the fact is that FF and IE don't like this. The should tests suite does pass in chrome however, if your curious.

Unfortunately, nothing can be done. My recommendation is to use the expect interface:

var expect = chai.expect
  , foo = 'bar';

expect(foo).to.be.a('string');
expect(foo).to.equal('bar');
expect(foo).to.have.length(3);

All of the same language applies.

from chai.

jgallen23 avatar jgallen23 commented on May 20, 2024

Very odd.

This seems to work fine in firefox:

Object.defineProperty(Object.prototype, 'should', {                                                                          
 get: function() {
     console.log(this);
 }
});
var a = '123';
console.log(a.should);

What, specifically, does firefox not like? It seems like it's fine with extending the Object.prototype, but all strings, numbers, etc, turn into object literals inside the property? is that right?

from chai.

logicalparadox avatar logicalparadox commented on May 20, 2024

Found a bit of a work around. Check out branch bug/issue-6 ... 067d966

Should tests for this branch are passing in Chrome 16, FF 9.0.1, Safari 5.1.2.

Let me know if it works out and I will pull it into the next release later today/tomorrow.

from chai.

jgallen23 avatar jgallen23 commented on May 20, 2024

I just grabbed 0.1.7 and everything works great in firefox now. Thanks!

from chai.

logicalparadox avatar logicalparadox commented on May 20, 2024

This patch has been included in 0.1.7. The commit was 48f3815 if your curious.

I also retract my previous statement. Apparently something can be done. Thanks for the motivation :)

Let me know if it troubles you further.

from chai.

jgallen23 avatar jgallen23 commented on May 20, 2024

FYI, it's really close to working in IE9 as well. For some reason any number sets this == 0. Trying to figure out a workaround. Other than that, everything seems to work

from chai.

logicalparadox avatar logicalparadox commented on May 20, 2024

That would be awesome if it did. Thanks for the update... will accept pull requests!

from chai.

jfirebaugh avatar jfirebaugh commented on May 20, 2024

Should the website be updated? It still says "Should tests do not run in the browser."

from chai.

logicalparadox avatar logicalparadox commented on May 20, 2024

Yeah, the api also a few versions outdate. I'm in the process of updating my docs generator so should be up in a day or two. Opened #12 in response.

from chai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.