mootools / mootools-core

MooTools Core Repository
https://mootools.net
2.65k stars 510 forks source link

Spec update #2734

Closed timwienk closed 9 years ago

timwienk commented 9 years ago

I decided to update our specs a bit, for a number of reasons:

  1. I noticed that we use two incompatible versions of Jasmine within Core (1.3 and 2.3),
  2. The server specs seemed a bit incomplete,
  3. Mocha seems to be the most popular one nowadays, so for interoperability (say we want to include third party specs, or someone else wants to include Moo specs) this seems the most flexible.

When I started doing this, I didn't know how much work it'd be, and luckily it wasn't too bad. The problem is, though, that it'll look like a lot and it'll be a hell to review because of the sheer number of changes.

To be able to review it I split it up in parts, and I would like to suggest to review it by part, we could even merge it in by part. I didn't create Pull Requests, because every next Pull Request would include the changes from the previous Pull Request since they're not merged at this point. When reviewed, I guess they could be merged in, and I could actually create a Pull Request for every next one to make that easier.

So, the parts:

At the point of any of these commit the specs should still run fine and turn all green, I made the changes step-by-step to not accidentally change behaviours. (In fact, if we want to stick with Jasmine, we could decide to stop after part 5, or even after the expect.js commit of part 6.) The only exception to this is the Chai commit of part 6, everything runs fine, but Chai doesn't support IE older than 9, keeping the commit for history and reasoning, though.

In case it's easier (it probably is), I should be in IRC most of the time for comments or anything related.

Note for later: There are some things I didn't touch, like the test "bootstrapping". I think after these changes, it might be a good idea to look at the Gruntfile.js and files in the Tests directory. It looks like these things could be restructured to be easier to understand.

SergioCrisostomo commented 9 years ago

I read thru the changes and found nothing strange/wrong. Sent it to Travis also. Got green all over. I'm easy about changing to Mocha or staying with Jasmine.

Nice job! Thank you for the time you put into this! :+1:

arian commented 9 years ago

Very nice!

A few things:

timwienk commented 9 years ago

Some tests are disabled with using xdescribe, for example https://github.com/timwienk/mootools-core/compare/spec-update-part-3...spec-update-part-4#diff-d7242700ac47efe4e538390355c32968R50 Is that still valid, or was it disabled at some point and never enabled again?

The specs where there's now xdescribe, there used to be a xit, so yea, they were disabled and never re-enabled. I believe they're tests from our old spec engine with PHP stuff. [intended]

I did just realise that if they were enabled, they'd fail now, because Mocha uses arguments to done as reasons a spec failed, while Jasmine has done.fail for that. [fixed]

chai uses expect(..).to.be.true, where true is a keyword. iirc that doesn't work in IE8, and should be to.be['true']. Is that relevant? (https://github.com/chaijs/chai/issues/124#issuecomment-11639702)

That's a good point. I kind of assumed they made it work. The best workaround is probably to use replace to.be.true with to.equal(true). The same thing should be the case for to.be.false and to.be.null. Will look into that. [fixed]

It should be fine for to.be.undefined, however, for the sake of consistency, maybe we should replace those as well. [fixed]

arian commented 9 years ago

That's a good point. I kind of assumed they made it work. The best workaround is probably to use replace to.be.true with to.equal(true). The same thing should be the case for to.be.false and to.be.null. Will look into that.

This is one of the reasons I initially used https://github.com/Automattic/expect.js (and kept using it since, I think chai wasn't really a thing then, the other choice was 'should.js').

timwienk commented 9 years ago

This is one of the reasons I initially used https://github.com/Automattic/expect.js (and kept using it since, I think chai wasn't really a thing then, the other choice was 'should.js').

Chai seems a very complete solution, including assert style assertions as well, which could benefit us in the future. However, if things don't work in IE older than 9, we should probably switch. Although I prefer some specific things Chai did with the expect syntax, the syntax of all expect style things are very similar anyway. [fixed]

timwienk commented 9 years ago

After looking at things, they clearly state they don't support IE<9, so Chai is not an option. I replaced it with the library Arian suggested, expect.js. [fixed]

arian commented 9 years ago

:+1:

timwienk commented 9 years ago

New issues encountered:

Latest test results: https://travis-ci.org/timwienk/mootools-core/builds/82323286

SergioCrisostomo commented 9 years ago

Nice work!

I am ok with merging these to master branch.

timwienk commented 9 years ago

@arian: Add node_js 4 here as well?

Never mind, it's already included in the other matrix.

Yes, what I changed in .travis.yml is: instead of adding the multiple node_js versions when building the matrix, only one is used for that, and the non-current versions are "manually" included after the matrix is built for only server testing. That way we don't have 75 runs of which 48 actually do nothing.

@arian: However if you use version 4, will it automatically use the latest 4.x version? As they are using proper semver now, all 4.x versions should automatically work.

That's a good point, I'll change that and hopefully they indeed don't break within the major version. :-D [fixed]

https://travis-ci.org/timwienk/mootools-core/builds/82406894

timwienk commented 9 years ago

Okay, so everything seems to work. Now for the last two questions:

  1. Do we agree on switching to Mocha? What are the reasons not to?
  2. When we go and merge, shall I PR this:
    • with everything in one PR,
    • as 6 separate PRs; one per part,
    • or two PRs; one for the first 5 parts, one for the mocha stuff?
arian commented 9 years ago
  1. Because of the effort of porting it. But you already did this.
  2. Two PRs would be a nice separation I think.
SergioCrisostomo commented 9 years ago

I say same as @arian.