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

PhantomJS does not recognize assertion #18

Open
billpull opened this issue Aug 5, 2016 · 0 comments
Open

PhantomJS does not recognize assertion #18

billpull opened this issue Aug 5, 2016 · 0 comments

Comments

@billpull
Copy link

billpull commented Aug 5, 2016

Added a custom assertion and it runs fine in Chrome but fails in PhantomJS.

Expected at least one assertion, but none were run - call expect(0) to accept zero assertions

  • ember-cli: 2.4.2
  • node: 4.3.2
  • PhantomJS: 2.0

My custom assertion is pretty long where attempting to do a pushResult on a bunch of expected behavior that originally was multiple assertions.

export default function userMessage(context, message, messageText = '', numMessages = 1, type = 'error') {
  const userMessageEl = context.$('[data-test-userMessages]');
  if (!userMessageEl) {
    return this.pushResult({
      result: false,
      actual: 0,
      expected: numMessages,
      message: `${message} - User Message Did Not Appear`
    });
  }

  const actualNumMessages = userMessageEl.length;
  if (actualNumMessages !== numMessages) {
    return this.pushResult({
      result: false,
      actual: actualNumMessages,
      expected: numMessages,
      message: `${message} - Unexpected User Messages`
    });
  }

  const actualMessage = context.$('[data-test-userMessageDetail').text().trim();
  if (messageText && (messageText !== actualMessage)) {
    return this.pushResult({
      result: false,
      actual: actualMessage,
      expected: messageText,
      message: `${message} - Incorrect Message Text`
    });
  }

  const expectedTypeClass = `user-messages__message--${type}`;
  if (!userMessageEl.hasClass(expectedTypeClass)) {
    const actualClasses = userMessageEl.attr('class');
    return this.pushResult({
      result: false,
      actual: actualClasses,
      expected: expectedTypeClass,
      message: `${message} - Incorrect Type Class`
    });
  }

  const expected = `${numMessages} - ${messageText}`;
  const actual = expected;
  return this.pushResult({
    result: true,
    actual,
    expected,
    message
  });
}
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

No branches or pull requests

1 participant