Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New API Iteration #258

Closed
wants to merge 3 commits into from
Closed

[WIP] New API Iteration #258

wants to merge 3 commits into from

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Mar 23, 2017

This is an effort to reduce ember-qunit's surface area, and leave the "testing framework" work to QUnit.

It is heavily inspired by the work that @Turbo87 did for ember-mocha (checkout their API here).

Sample integration test with the new API:

import { module, test } from 'qunit';
import { buildIntegrationOptions } from 'ember-qunit';

module('component:x-foo', buildIntegrationOptions({
  beforeEach() {
    // special setup stuff
  }
}));

test('renders', function(assert) {
  assert.expect(1);

  this.render(hbs`{{pretty-color name="red"}}`);

  assert.equal(this.$('.color-name').text(), 'red');
});

I've also added work to enable an even nicer API (IMHO of course) with nested modules, but that effort is blocked by qunitjs/qunit#977.

The nested modules API would look like:

import { module, test } from 'qunit';
import { setupIntegrationTest } from 'ember-qunit';

module('component:x-foo', function(hooks) {
  setupIntegrationTest(hooks);

  test('renders', function(assert) {
    setupRegistry();
    assert.expect(1);

    this.render(hbs`{{pretty-color name="red"}}`);

    assert.equal(this.$('.color-name').text(), 'red');
  });
});

@Turbo87
Copy link
Member

Turbo87 commented Mar 23, 2017

:shipit:

@rwjblue
Copy link
Member Author

rwjblue commented Apr 3, 2017

Need to add options.after to clear module so that it does not get retained.

Thanks to turbo87 for working on a very similar API in ember-mocha,
this is largely a copy/paste of that effort...
@Turbo87
Copy link
Member

Turbo87 commented Apr 12, 2017

@rwjblue rebased and added the after block

@rwjblue
Copy link
Member Author

rwjblue commented Apr 12, 2017 via email

@Turbo87
Copy link
Member

Turbo87 commented Apr 13, 2017

@rwjblue looking at the examples above, do you want to use the test module name as the descriptor for the thing to be tested? that seems a little error prone to me and will not allow people to specify a more readable name explicitly like in the new Mocha API.

@trentmwillis
Copy link
Member

I agree with @Turbo87. It should be like:

module('Some description', function(hooks) {
  setupIntegrationTest('component:foo-bar', hooks);
});

// or

module('Some description', buildIntegrationOptions('component:foo-bar', {}));

@rwjblue
Copy link
Member Author

rwjblue commented Apr 13, 2017

@trentmwillis - The argument that you pass to setupIntegrationTest there is not needed or used for anything, only the current "unit tests" use that argument (and I don't intend to add back that monstrosity)...

@trentmwillis
Copy link
Member

Well for the ones that need it, I was just modifying the existing example. I assume it is still needed for unit tests.

@jbescoyez
Copy link

@rwjblue It looks like this PR will fix #208 and allow nested modules. What's the current status of this PR. How can I help?

@rwjblue
Copy link
Member Author

rwjblue commented Oct 8, 2017

I spent a ton of time this weekend making progress on this. The first major step was to migrate ember-test-helper and ember-qunit to be "real" addons (to allow faster iteration here).

The next step is cleaning up some testing infrastructure in ember-test-helpers (to ensure that things work properly without jQuery) before starting in on the new API. You can follow that effort in emberjs/ember-test-helpers#215.

After that lands (and we release 0.7.0 of ember-test-helpers), I will begin working on the "real" implementation of emberjs/rfcs#230 (which replaced this spike).

@rwjblue
Copy link
Member Author

rwjblue commented Oct 8, 2017

The best way to help at the moment is likely to help us in testing [email protected] (feel free to join us in #dev-testing in the community slack). Once [email protected] is hammered on by a few different folks/apps/etc we can move it out of beta allowing further progress on the new API surface.

@rwjblue
Copy link
Member Author

rwjblue commented Oct 17, 2017

Closed by #286.

@rwjblue rwjblue closed this Oct 17, 2017
@rwjblue rwjblue deleted the next branch October 17, 2017 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants