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

Updating readme with information about async tests #50

Merged
merged 1 commit into from
Jun 18, 2014

Conversation

Emerson
Copy link
Contributor

@Emerson Emerson commented May 16, 2014

Took me 2-days to figure this out, so I'd like to ensure others have an easier time :-)

@stefanpenner
Copy link
Member

also, it asserts fulfillment of that promise and automatically does start/stop's for you

@Emerson
Copy link
Contributor Author

Emerson commented May 16, 2014

Also, just found out that if you return a promise that rejects, it's triggers a failed test (so you need to wrap it in another promise)... which I guess is exactly what you just said!

@stefanpenner
Copy link
Member

@Emerson sorta, that is a feature. You never want to return a "failed" promise, as that is a failure.

@Emerson
Copy link
Contributor Author

Emerson commented May 16, 2014

What about a case like this? My authentication object sets error messages:

test('it sets the errors on failure', function() {
  mockHttp('/sessions', 'sessions/create_failure', 422);
  var authentication = Authentication.create();
  expect(3);
  return authentication.authenticate('test@test.com', 'wrong', true).catch(function(err) {
    equal(authentication.get('errorMessage'), 'Invalid username or password', 'errorMessage is set');
    equal(authentication.get('errors.email.firstObject'), "Invalid", 'errors object is set');
    equal(authentication.get('errors.password.firstObject'), "Invalid", 'errors object is set');
  });
});

@stefanpenner
Copy link
Member

@Emerson catch that doesn't re-throw becomes a success. If you have an error here, you really do have a genuine test failure.

fivetanley added a commit that referenced this pull request Jun 18, 2014
Updating readme with information about async tests
@fivetanley fivetanley merged commit a872e44 into emberjs:master Jun 18, 2014
@fivetanley
Copy link
Member

👍 Thanks! I'll add in stef's comments in a bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants