Skip to content

Loading…

Tape #1459

Closed
wants to merge 4 commits into from

5 participants

@braddunbar
Collaborator

Currently, Underscore is not routinely tested in a node environment or across multiple browsers unless it's done manually. This causes errors to slip through undetected (I point this out to illustrate that they slip through as we all make errors of this kind from time to time). In an attempt to improve the testing situation a bit, this patch replaces QUnit with tape with the following benefits.

Note: Running tests now requires a build step, something we can probably work around if necessary.

@braddunbar braddunbar commented on the diff
test/collections.js
((66 lines not shown))
var doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
- equal(doubled.join(', '), '2, 4, 6', 'OO-style doubled numbers');
-
- if (document.querySelectorAll) {
- var ids = _.map(document.querySelectorAll('#map-test *'), function(n){ return n.id; });
- deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on NodeLists.');
- }
@braddunbar Collaborator

From what I can tell, this just tests array-likes and need not use the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jashkenas
Owner

Epic. Sounds great. Feel free to merge if other folks agree.

@tbranyen

Hey @braddunbar I know you already did the work, but did you check out running tests with Mocha using this QUnit adpater?

@akre54
Collaborator

Don't know much about tape, but +1 to getting rid of qunit (and in BB too)

@jdalton
Collaborator

Awesome work getting some kind of browser automation up! :dancer:

It does have some down sides though:

  • Requires building for devs to run in the browser (like http://underscorejs.org/test/)
  • Required a rewrite of all unit tests (that's been paid)
  • Doesn't support testing IE compat mode. Underscore has fixes for bugs found in IE compat modes but Testling does not support compat modes so this would still require firing up those VMs.
  • Testling seems unpolished

    • When I went to check the IE8 failure from your test run. I clicked on the "open" link to run the tests on my browser. It ran in the console. I happened to switch tabs while running so it caused some async tests to fail. Looking for the fails required hunting through a large backlog of messages.

    • When I clicked on the "debug in browserling" link it just sat in the queue:

What's nice about QUnit is you can configure it to only show fails to reduce the clutter. It also has nice runner options like checking for leaked globals and linking to specific tests.

I've gotten QUnit working in Node & other environments with the help of qunit-extras.
What's nice is my tests run in browsers, Node, and everywhere in between. I'm able to get code coverage reports & browser test automation all while running the same tests for various builds/environments.

I use Sauce Labs which

  • Supports testing in QUnit
  • Supports IE compat mode so I don't have to crack open a VM
  • Allows parallel test runs (more browsers tested at once to finish faster)
  • Can record screencasts of your test runs
  • Allows you to jump into live tests and take control
  • Supports tag and filter test runs
  • Has the sauceops Twitter account to track its operational status

As I said I think supporting browser test automation is great, I wish it didn't come at degrading the testing experience.

Collaborator

If you're up for it I'd dig helping you with setting things up w/ sauce.

@braddunbar
Collaborator

@tbranyen I haven't, but I'll give it a look. Thanks!

@akre54 I'm curious, what are your complaints about QUnit? To be honest, I rather love QUnit but to my knowledge using it for the goals above requires lots of adapters and workarounds. (@jdalton uses it for that purpose though, so I'll look into that.)

@akre54
Collaborator

Mostly I don't like its syntax and how difficult it is to run in node compared to some of the more modern projects like Jasmine and mocha (hadn't seen jdalton's setup... might try that out).

@jashkenas jashkenas added the change label
@jashkenas
Owner

Seems like QUnit w/QUnit-extras is the potentially more promising approach ... so closing this in favor of a future PR that goes in that direction...

@jashkenas jashkenas closed this
@jashkenas jashkenas added the wontfix label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.