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

Reduce direct jQuery usage in tests. #215

Merged
merged 13 commits into from
Oct 9, 2017

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Oct 8, 2017

  • add test scenarios that run without jQuery (defaulting to jQueryless setup)
  • refactor all tests to avoid jQuery usage
  • embed custom eventing test helpers (until we can bring ember-native-dom-helpers into the fold)

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please!

@@ -760,7 +763,7 @@ moduleForComponent('Component Integration Tests: willDestoryElement', {
'component:my-component': Component.extend({
willDestroyElement() {
var stateIndicatesInDOM = this._state === 'inDOM';
var actuallyInDOM = $.contains(document, this.$()[0]);
var actuallyInDOM = document.contains(this._element);

QUnit.config.current.assert.ok(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably break this up into two assertions so you can get more granular feedback when it fails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, great point!

Updating the resolver to fallback to "real" resolving (so that we can
automatically get the event_dispatcher:main for jQueryless usage) leads
to some tests failing now due to `application.hbs` having the text
contents of the welcome page component.

Remove this template so that it doesn't interfere with the existing
tests...
Without this looking up `event_dispatcher:main` does not find the event
dispatcher that is normally provided by
ember-native-dom-event-dispatcher.
Mostly copied/stolen from emberjs's packages/ember-testing/lib/events.js
but with some tweaks to make it work without jQuery (I think those
changes were made upstream in Ember as well).

The long term goal here is to remove this file and have
ember-test-helpers _include_ the helpers from ember-native-dom-helpers,
but that will require an RFC once the changes proposed in
emberjs/rfcs#230 are implemented.
When a given test is explicitly testing jQuery behaviors, this helper
will be used...
Apparently, the dummy app _must_ have an `app/templates/` tree. 😡
@rwjblue
Copy link
Member Author

rwjblue commented Oct 9, 2017

Updated with lots more changes. Tests are passing locally without jQuery (and scenarios were added to ember-try config to test with and without jQuery). Playing a bit of whack-a-mole with various issues in CI, but generally speaking I think this pretty close...

The built-in `packages/ember-testing` does not work for acceptance
tests in 2.12.
@rwjblue
Copy link
Member Author

rwjblue commented Oct 9, 2017

Finally green.

@rwjblue rwjblue merged commit f8e89cf into emberjs:master Oct 9, 2017
@rwjblue rwjblue deleted the test-without-jquery branch October 9, 2017 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants