-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
beta.2 model unit tests failing w/codemod #289
Comments
Thank you for reporting! I was discussing with @Turbo87 in slack as well. For now, the work around is to call |
Would you mind also sharing what the failures with the transform of |
Will do, tonight. I also plan on switching to the async/await style tests ember-native-dom-helpers per this ticket. |
test (before codemod) component error:
after codemod: import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from 'ember-test-helpers';
import hbs from 'htmlbars-inline-precompile';
import {
registerTestComponent,
unregisterTestComponent
} from
'mir/tests/ember-test-component';
module('Integration | Component | ma auth', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function({ test: testCtx }) {
unregisterTestComponent(testCtx.testEnvironment);
});
test('it renders the signup form', async function(assert) {
registerTestComponent(this);
this.set('loginAction', function login() {});
this.set('signupAction', function signup() {});
await render(hbs`
{{ma-auth title="ABC_"
components=(hash
login=(component "test-component")
input=(component "test-component"))
loginAction=loginAction
action=signupAction}}
`);
let actual = this.$().text().trim().replace(/[\s\n]+/g, '');
assert.notEqual(actual.indexOf('ABC_'), -1);
assert.notEqual(actual.indexOf('Signup'), -1);
});
}); |
Its got something to do with my use of ember-test-component. when The owner is not resolved in |
Awesome, thanks for digging! The specific issue you are hitting with the rendering test is indeed an issue with the You can work around (if you want to) via something like this: module('Integration | Component | ma auth', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function() {
Ember.setOwner(this, this.owner);
});
// .... existing contents ....
}); Note: this is really just a work around until poteto/ember-test-component#7 lands... |
This workaround worked, i'm going to close this ticket here, and i'll keep watching over at My final test w/workaround looks like this: import { setOwner } from '@ember/application';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from 'ember-test-helpers';
import hbs from 'htmlbars-inline-precompile';
import {
registerTestComponent,
unregisterTestComponent
} from 'mir/tests/ember-test-component';
module('Integration | Component | ma auth', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function({ test: testCtx }) {
setOwner(this, this.owner);
unregisterTestComponent(testCtx.testEnvironment);
});
test('it renders the signup form', async function(assert) {
registerTestComponent(this);
this.set('loginAction', function login() {});
this.set('signupAction', function signup() {});
await render(hbs`
{{ma-auth title="ABC_"
components=(hash
login=(component "test-component")
input=(component "test-component"))
loginAction=loginAction
action=signupAction}}
`);
assert.notEqual(this.element.textContent.trim().indexOf('ABC_'), -1);
assert.notEqual(this.element.textContent.trim().indexOf('Sign up'), -1);
});
}); |
Awesome, thanks for working through that @0xadada! |
version ember-cli-qunit 4.1.0-beta.2
Synopsis
Just read @rwjblue blog post and ran the codemod converting the tests to 4.1.0-beta.2 tests API.
I ran codemod incrementally, and most of the codemod changes produced successful converstions with passing tests. Two exceptions are
tests/unit/models/*
andtests/integration/components/*
which are failing.Here is an example for a model unit test
before codemod:
tests/unit/models/user-test.js
after codemod
error
repo/branch: https://github.com/mirai-audio/mir/tree/testing-qunit-codemod/tests
The text was updated successfully, but these errors were encountered: