walmartlabs / thorax

Strengthening your Backbone
http://thoraxjs.org/
Other
1.32k stars 129 forks source link

Make unit tests run on IE8 #88

Closed eastridge closed 10 years ago

eastridge commented 11 years ago

Chai doesn't work with IE8, we need to upgrade to latest chai when it comes out or use another lib. Discussion here:

https://github.com/chaijs/chai/issues/124

Note that for what it's worth the sample thorax apps run on IE8.

GeorgeErickson commented 11 years ago

I plan to spend a few hours on this this weekend, and had a few questions.

  1. Where is the mocha dependency coming from, is it phoenix-build?
  2. Are you opposed to using expect.js over chai.expect?
kpdecker commented 11 years ago
  1. Yep this should be the case.
  2. What are the differences between the two libraries? What would moving to expect.js provide?

A little bit of background, the phoenix-build project is utilized by most of our external and internal projects and I'd like to keep things somewhat uniform for the sanity of the team :)

GeorgeErickson commented 11 years ago

It provides a much more limited subset of expect but works in IE 7. It looks like you guys use some of the more special parts so moving to expect.js probably wouldn't be a good idea.

I'll actually spend this weekend getting chai.expect to work in IE 7, they use a handful of easily polyfilled functions so it shouldn't be too bad.

eastridge commented 11 years ago

@GeorgeErickson @kpdecker anyone know the state of chai on IE8? Can't find any updates. On the Thorax side I think we will eventually have to care about IE8.

eastridge commented 11 years ago

And incidentally it works on IE8, at least some simple demos do.

akre54 commented 10 years ago

@eastridge any luck with using an Object.create pollyfill? It looks like chai isn't doing anything particularly interesting that couldn't be stubbed with ES5-shim / ES5-sham (and since it's only being used for tests, support doesn't have to be 100%).

I can take a stab at it, but I freely admit I'm a bit lost when trying to figure out how to get Throax tests to run in the browser. Is there a wiki somewhere?

eastridge commented 10 years ago

@akre54 If you think it's that simple I'd love for you to take a stab at that.

Re: running the tests, this is non obvious. I've added a README with notes:

https://github.com/walmartlabs/thorax/tree/master/test

akre54 commented 10 years ago

Welp, I forgot that Object.defineProperty only works on DOM nodes in IE8... no easy solution around this. Maybe the chai guys could add a fallback for expect(obj).to().be().truthy()?

kpdecker commented 10 years ago

@akre54 the Object.create polyfil only gets you past the first error. The much larger issue is the use of defineProperty which there doesn't seem to be a good way to work around. I believe that rewriting in expect.js is the only option given then interest that the Chai team has shown in supporting anything below IE9.

akre54 commented 10 years ago

Yeah totally. I'm not a huge fan of Object.defineProperty because it's not always clear that the value is meant to be called as a function. It'd be nice if chai had an alternative interface like the one above, but in the meantime expect.js might be the best bet.

kpdecker commented 10 years ago

I should have been a bit clearer when I closed this. Master is running IE8 tests now. https://travis-ci.org/walmartlabs/thorax/builds/20200198#L2040

akre54 commented 10 years ago

oh sweet. :+1:

kpdecker commented 10 years ago

Released in v3.0.0-alpha.1