-
Notifications
You must be signed in to change notification settings - Fork 0
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
[RFC] Initial design #1
Comments
Regarding callback-style vs. async/await, detecting which style is used should be easy. Mocha does the same, see https://mochajs.org/#asynchronous-code. I think the way would be to check the (sync) return value of the function. If it is a promise (i.e. has a It's not clear to me which step implementation gets imported for a given feature. Is Where should feature files live, also under Agree we should not spend time on localization, never ever used it... |
My plan was for Basically, I would like to retire
This splitting is similar to:
That's awesome, thanks!
A If it does, then it will be used (allowing for legacy If a steps file does not exist, then a default set of steps will be loaded from
Under |
Not sure what exactly this means in this context...
Ok, that's one thing, but does that mean that So basically still unsure why the testing framework ( That aside, the idea of separate minimal addons seams reasonable. Two things come to my mind:
See e.g
Does that mean it would have to import and mix-in the generic steps from
How would that work (the non-conflicting part)? Also worried if feature and step files shouldn't be closer together (aka co-located)? But maybe it's ok, more thinking aloud... |
Both approaches could work. On the one hand, putting the labels logic into One the other hand, putting the labels logic into But I believe that it's easier to teach and causing less frustration when everything is in one place. If labels logic is in If yes, then the If no, the why put part of Let's make |
👍
I also have no experience with monorepos and I've seen projects having FAQ entries explaining why they don't want to be monorepos, so initially I was hesitant about it. I think monorepos are appropriate for projects where a big app is based on multiple self-owned dependencies. We have the opposite: a number of child addons, each depending on a core addon. But after reading a few posts on monorepos and giving it a thought, I'm ready to try it out. The codebase is gonna be small enough for many of monorepo downsides to be irrelevant, and making breaking changes should require much less effort. Also, new experience! |
If If By adjusting the content of
|
Instead of turning a
The opinionated approach does not suppose having per-feature steps files. That's unless you're gonna do number 2 from the previous comment, but that's more like an escape hatch for a non-standard situation rather than a normal workflow. And if you do that, no one is stopping you from placing your per-feature steps next to the feature. It's entirely up to the user. The legacy |
@simonihmig This article says that monorepos are awesome, but Lerna approach to monorepos is bad: https://blog.nrwl.io/misconceptions-about-monorepos-monorepo-monolith-df1250d4b03c |
File locations
/tests/yadda/steps.js
/tests/yadda/steps/<my-steps>.js
steps.js
/tests/yadda/dictionary.js
string | Regexp | [string | RegExp, (string[]) => Promise<any> ]
/tests/yadda/labels.js
string
, e. g.{'Bootstrap-Primary-Button', '.btn-primary')
/tests/yadda/annotations.js
Populating the dictionary
Yadda has a weird API for defining the dictionary:
This Node-style callback is inconvenient and hard to type. Basically, you pass a callback that accepts a callback.
ember-yadda
uses a simplified way of defining the dictionary:Under the hood,
ember-yadda
will convert these straightforward callbacks into Node-style supported by Yadda like this:Now it is very convenient to define converter macros, but existing converters from
Yadda.converters
are Node-style. I see three ways to resolve this:When defining a macro using a
Yadda.converters
converter, use an util on it so that it is wrapped with async/await that the addon supports.E. g. instead of:
you would do:
The downside of this approach is that a Node-style converter will be wrapped with async/await by the util and then wrapped again with Node-style by the addon.
Have
wrapConverterWithNodeStyle
detect whether the converter is Node-style or async/await.One way to do this would be to use introspection:
The downside of this approach is that it's magical and unreliable, since it assumes that a node-style callback has its last argument called
next
. It will fail both when aYadda.converters
converter has the last argument called differently (currently not the case) and when an async/await converter has its last argument callednext
.There's also a performance implication, but it should be negligible.
Maybe there's another way to distinguish Node-style
Yadda.converters
converters from async/await converters?Simply port all six
Yadda.converters
converters, so that either theember-yadda
addon or a separate content-oriented addon offers async/await equivalents.Downside: more work to do. I was gonna write "more maintenance", but after ensuring test coverage the code will not need to be revisited.
We'll also need to maintain compatibility with
Yadda.converters
, but I doubt that they will stray far from what they currently are.Supporting legacy
ember-cli-yadda
In the legacy
ember-cli-yadda
, a test file generated from a feature file imports a matching steps file like this.We could make this import conditional. If the steps file exists, run it using the legacy setup. Otherwise, use the new setup described above.
Within the steps file, the user has complete freedom. They can:
ember-cli-yadda
.ember-cli-yadda-opinionated
. This lets you use legacyember-cli-yadda
steps and opinionated steps in the same feature.Things not covered
Localization
Previously, localizaton setup was happening in the app.
Due to drastically simplified design of addon's in-app files, the addon will have
yadda.localisation.default
hardcoded.I believe internationalized steps are a bad practice, so we should not bother making it configurable.
In future, if there's a feature request for supporting non-English locales, we'll be able to think about a way of making it configurable.
The text was updated successfully, but these errors were encountered: