Closed esamattis closed 8 years ago
Relying on key order seems to be frowned-upon, and apparently could stop working any day:
While other current Javascript engines enumerate object properties in insertion order, V8 orders properties with numeric keys in numeric order.
(http://book.mixu.net/node/ch4.html - section 4.3)
This means that any step name which is parseable as a number will be inserted above other non-number steps.
So let's say we have steps named:
"foo", "2 foo", "1 bar"
They would get executed in the order you have them defined.
But if you had:
"foo", "2", "1 bar"
They would get executed in the order: "2", "foo", "1 bar"
This is probably unlikely, as most folks would give their test steps descriptive names, and not just a number. But it might be worth calling out in the docs that we're relying on non-spec behavior of V8.
I really would like to see some other syntax for defining steps. I feel uncomfortable relying on it after years of avoiding doing that...
Suggestion:
module.exports = function(step){
step("step one", function(browser) {
});
step("step two", function(browser) {
});
};
It would be possible to support this while not breaking the current behavior.
Closing due to inactivity and also this is now possible with using mocha runner.
In this example http://nightwatchjs.org/guide#write-tests there is "step one" and "step two" but how Nightwatch.js knows how to run the "step one" before "step two" since the order of the keys in objects are not guaranteed in javascript?