-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Make runner methods chainable. #243
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
Conversation
@@ -5,6 +5,7 @@ var Promise = require('bluebird'); | |||
var hasFlag = require('has-flag'); | |||
var Test = require('./test'); | |||
var send = require('./send'); | |||
var objectAssign = require('object-assign'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: We probably should look in to replacing some of these polyfills with core-js
equivalents. Hopefully cutting down on duplicate downloads for users.
I'm getting close to turning this into some cool chaining functionality.
I need sleep now though. More tomorrow. |
I like where this is going :) Chaining is an important step as it will let you skip a test without losing the type of test. Right now you can't have a skipped test that is serial. You have to remove the |
OK - saw my error - chaining should now work. This needs some cleanup (see the various TODO's), documentation, and more test coverage. I should be able to wrap it up this weekend. When it comes time to make nested groups, we will continue along the same pattern here, but replacing the base I also need to add the inverse of most of the boolean flags. (i.e. concurrent = {serial: false}). That would be used for making a few tests concurrent in a group of tests where the default is serial. In all, I think doing it this way is going to open up some really cool stuff. OK - bedtime for real now. |
I am starting to think all these flags belong on a
Otherwise we need to always be careful the metadata properties never share a name with a useful property. (For example we can not use |
Useful properties are going to be hard to predict as well, especially once we enable custom assertions. |
f298d72
to
65c1ce3
Compare
runner.js: simplify test data structure split hooks to their own file auto-generate runner.addXXX functions add chaining drop `map-obj` as a dependency (I did not end up needing it). refactor tests to use chained methods simplify chain builder add chainable tests make all hooks skippable test title of skipped test move test flags to metadata object, instead of right on test remove unused property
65c1ce3
to
3029466
Compare
runner.js: simplify test data structure split hooks to their own file auto-generate runner.addXXX functions add chaining drop `map-obj` as a dependency (I did not end up needing it). refactor tests to use chained methods simplify chain builder add chainable tests make all hooks skippable test title of skipped test move test flags to metadata object, instead of right on test remove unused property
return filter[key] === test.metadata[key]; | ||
}); | ||
} | ||
return this.tests.filter(filterFn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put the filter function inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wish I could use arrow functions 😞
@jamestalmage Reviewed. This looks very good. Could you update the readme about the methods being chainable? |
I don't really understand the point of Otherwise, I really like the idea behind this PR. |
It's for beforeEach / afterEach. Which need to be created multiple times. It's just storing the constructor args for later invoke (multiple times) |
@jamestalmage makes sense! |
👍 Landed. Superb work on this one @jamestalmage :) |
This flattens the entire
runner.tests
data structure into a single array.Elements of the array are then chosen using
runner.select(selectorObject)
.The selector currently just compares its own properties to each test, and selects those that have matching properties. It will be easy to expand with
groupMembership
queries, etc.