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

Evented/Timed test helpers #121

Closed
johnbender opened this issue Jul 4, 2011 · 3 comments
Closed

Evented/Timed test helpers #121

johnbender opened this issue Jul 4, 2011 · 3 comments

Comments

@johnbender
Copy link

Evented testing

DISCLAIMER: most of the ideas here may be project specific but appear, at least from where I'm standing, to be useful in a myriad of scenarios when testing event based functionality.

Timing and event based tests in QUnit and other frameworks tend to be fragile and even dependent on execution order in practice. There are few test helpers that we've found to be invaluable in working with events and time dependent functionality.

sequence( functions, timeout )

Many tests that require a set of timeouts to verify functionality can be cleaned up by abstracting multiple calls to setTimeout into a single helper. This is just as brittle as using the timeouts themselves but at least results in cleaner code where no event is provided to guarantee the behavior.

Example:

https://github.com/jquery/jquery-mobile/blob/master/tests/unit/navigation/navigation_core.js#L49

eventSequence( event, functions )

The event sequence helper executes a list of functions based on a series of the same event firing to trigger each. The most obvious use case where jQuery Mobile is concerned is page transitions which fire the changepage event upon completion.

An example from the event tests:

https://github.com/jquery/jquery-mobile/blob/master/tests/unit/event/event_core.js#L425

An example from the navigation tests. pageSequence is just a wrapper around eventSequence that specifies changepage event as the first argument to eventSequence:

https://github.com/jquery/jquery-mobile/blob/master/tests/unit/navigation/navigation_core.js#L300

eventCascade( event, function, event, function ... )

We haven't stumbled upon a use case here yet but it seems likely that a more flexible form of the eventSequence function would be valuable. In fact this should encourage a more pluggable design since events will be the preferred way to guarantee states of execution in the code being tested!

waitFor

Jasmine has a nice helper in the form of waitFor. It holds the test suite execution until the callback returns a truthy value. Mind you this is dependent on the serialization of all the code in the tests through the run function. More information can be found at their wiki down on the bottom:

https://github.com/pivotal/jasmine/wiki/Asynchronous-specs

@jzaefferer
Copy link
Member

I wonder if this somewhat overlaps with #99

@jzaefferer
Copy link
Member

Hey @johnbender - you still interested in this?

@jzaefferer
Copy link
Member

Closing this, as the linked-to source is outdated. @johnbender will put together an update in a new ticket, working with @rwldrn to get his Popcorn.js perspective involved.

stefanpenner added a commit to stefanpenner/qunit that referenced this issue Jun 6, 2018
I think chokidar is great, but the ergonomics around native dependencies today in node really painful. Although chokidar pre-builds, users switching nodes, or failed pre-build downloads, or behind firewall usages cause a fallback to requiring a working compiler toolchain. Requiring that, very much increases the barrier of entry, and support load for tooling/cli maintainers
stefanpenner added a commit to stefanpenner/qunit that referenced this issue Jun 6, 2018
I think chokidar is great, but the ergonomics around native dependencies today in node really painful. Although chokidar pre-builds, users switching nodes, or failed pre-build downloads, or behind firewall usages cause a fallback to requiring a working compiler toolchain. Requiring that, very much increases the barrier of entry, and support load for tooling/cli maintainers
stefanpenner added a commit to stefanpenner/qunit that referenced this issue Jul 27, 2018
I think chokidar is great, but the ergonomics around native dependencies today in node really painful. Although chokidar pre-builds, users switching nodes, or failed pre-build downloads, or behind firewall usages cause a fallback to requiring a working compiler toolchain. Requiring that, very much increases the barrier of entry, and support load for tooling/cli maintainers
stefanpenner added a commit to stefanpenner/qunit that referenced this issue Jul 27, 2018
I think chokidar is great, but the ergonomics around native dependencies today in node really painful. Although chokidar pre-builds, users switching nodes, or failed pre-build downloads, or behind firewall usages cause a fallback to requiring a working compiler toolchain. Requiring that, very much increases the barrier of entry, and support load for tooling/cli maintainers
trentmwillis pushed a commit that referenced this issue Jul 30, 2018
I think chokidar is great, but the ergonomics around native dependencies today in node really painful. Although chokidar pre-builds, users switching nodes, or failed pre-build downloads, or behind firewall usages cause a fallback to requiring a working compiler toolchain. Requiring that, very much increases the barrier of entry, and support load for tooling/cli maintainers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants