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

feature request: add a message to the options hash #26

Closed
iezer opened this issue Nov 24, 2015 · 7 comments
Closed

feature request: add a message to the options hash #26

iezer opened this issue Nov 24, 2015 · 7 comments

Comments

@iezer
Copy link
Contributor

iezer commented Nov 24, 2015

We'd like to be able to add a message to options that are passed to expectElement. This is useful because sometimes we have synchronous helpers for finding an element. Example:

// helper
findButton(app, buttonText) {
  return find(`button:contains(${buttonText})`);
}

// test
  expectElement(findButton('Save Profile')); 

If this fails, we get a cryptic message like found 0 of false but expected 1 or found 0 of [Object] but expected 1

We'd like to be able to do expectElement(findButton('Save Profile'), 1, options: { message: { 'Save Profile Button' }}) and see found 0 of Save Profile Button

Now that I'm looking at this example we can probably think of a better syntax but the general idea applies.

@bantic appreciate your thoughts.
CC @amyrlam @tundal45

@bantic
Copy link
Member

bantic commented Dec 4, 2015

@iezer Yeah, I think this would be great. Imo the most important thing is finding a good syntax for providing the message. Adding options: { message: '...' } seems ok, but do you have any ideas for something terser?

@tundal45
Copy link
Contributor

tundal45 commented Dec 4, 2015

@bantic We were thinking expectElement(findButton('Save Profile'), 'Save button displays correctly'); where the message is an optional parameter. CC @iezer

@iezer
Copy link
Contributor Author

iezer commented Dec 16, 2015

@bantic @tundal45 @amyrlam

We can detect if the 3rd parameter is a string or an object. In the former case use that string as the message, and in the latter look for a msg or message property, so
expectElement(findButton('Save'), 1, 'Save Button');
and
expectElement(findButton('Save'), 1, { msg: 'Save Button' })
would both work.

In either case we should swap that message into the complete message from the helper so we would display Found 0 of 'Save Button' but expected 1

@stefanpenner
Copy link

something I have found useful in async tests, is the ability to pause and resume tests. At work we are using this, and its quite nice. This differs from a debugger, in that you can still use and interact with the paused application, and differs from the existing pauseTest helper, because it can be resumed.

example:

import pause from './helpers/pause';

test("fooo", async () => {

  await visit('/foo');

  await pause(); // will pause here, but can be resumed by typing `resume`
  await click('#bar');

  // some assertions
})

codez: https://gist.github.com/stefanpenner/0baadd08d0733f9e8ae0

@amyrlam
Copy link
Contributor

amyrlam commented Feb 28, 2016

Submitted a PR. Please let me know if any feedback!

I think a good next step would be to change

expectElement(findButton('Save'), 1, { msg: 'Save Button' })

to just be

expectElement(findButton('Save'), 1, 'Save Button'); like assert.ok syntax

but not sure how to do that yet since options is { contains: 'foo', message: 'whatevs }

@iezer iezer mentioned this issue Mar 22, 2016
@iezer
Copy link
Contributor Author

iezer commented Mar 22, 2016

@amyrlam Can I close this issue?

I've opened a separate issue #32 for @stefanpenner 's suggestion to add a pause helper.

@amyrlam
Copy link
Contributor

amyrlam commented Mar 23, 2016

👍 and thanks for the help

@iezer iezer closed this as completed Apr 4, 2016
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

5 participants