-
-
Notifications
You must be signed in to change notification settings - Fork 41
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: Strict Step Registration #240
Comments
Would not step tagging per #205 be a solution for that? To have steps exclusively bound to entityEditor, you can define them with tag: Given(/I am on the "(.*)" page of "(.*)"/, { tags: '@entityEditor' }, async () => { ... });
Given(/I am on the "(.*)" page of a new inventory entry/, { tags: '@entityEditor' }, async () => { ... }); And in the feature file: @entityEditor
Feature: Entity Editor
... Other steps without tag are shareable across all features. I personally like even more the idea in #217, so we can put all entityEditor stuff into tagged folder and steps will be automatically bound to it:
All steps from Some other questions, to better understand the context:
|
@vitalets Thank you for your speedy response and detailed thoughts. I'll try address these thoughts individually. Ultimately, I completely respect the decisions you've made and your overall approach with
I did consider this, but ultimately I feel that traceability is such a "solved problem" on the javascript/typescript side, so to me it seems the most logical to use code, rather than file structure or tagging conventions, to drive traceability. Because of this, I organize my tests in pairs of
My team specifically doesn't have any dedicated "feature writers". The same devs who automate tests write feature files, and our QA specialists/Analysts simply review those feature files for gaps/unconsidered use cases.
Personally, I do not, no. Because most IDE tools that enable this feature, to my knowledge, rely on globs and implicit attachment of step definitions to feature files. And perhaps I'm overly overparticular about this, but I really value explicit dependencies over implicit dependencies. It's probably a result of trauma from my experiences in the early 2010s pre-modular javascript world. |
Thought more about that request. So the goal is to have To me #217 still looks like a solution. Imagine the following structure:
All steps will be bound to the respective feature. Or I'm missing something? |
This, but also the ability to explicitly register/share some or all steps of a different "feature". So, with the above structure it would be something like // @entityEditor/steps.ts
import { createBdd } from 'playwright-bdd';
export const entityEditor = createBdd();
entityEditor.Given(...)
entityEditor.Then(...)
const { Given, When, Then } = createBdd().use(entityEditor);
Given(....)
When(...)
Then(....) // @anotherFeature/steps.ts
import { entityEditor } from '../@entityEditor';
const { Given, When, Then } = createBdd(...).use(entityEditor);
Given(....)
When(...)
Then(....) The important thing being that I couldn't accidentally register steps just by the fact that I have made my original solution semi-workable by just making sure that every |
The problem
When it comes to code dependencies, I love traceability, and the fact that a step registered by a
Given
returned from a different invocationcreateBdd(test)
can be used in any generated test can often be a blocker to setting up traceable step sharing. Some people may prefer this ease of sharing, as it mimics the step sharing in cucumber, but personally, I prefer to group my steps by domain and require any test suite that wants to use those steps to explicitly call a registration type function.For example, a
step.ts
file I write for a high level feature might look like this:Certain of these steps are usable by other, more granular tests that are in different suites. I do want to expose those steps to be sharable (though only by explicit registration). Other steps in this file are more specific and I want them to not be usable elsewhere. This makes it very straight forward to find the specific step definition a given tests is using by tracing the import path in an IDE. It also prevents step discovery that is semi-"magical".
The above
shareSteps
utility is a small helper I wrote to create a registration function, and it looks like:This is fine, but it only creates the illusion of traceability, because the other, non-shared steps are still visible and available to any steps file that imports the first file, even if they only imported the file to use the
register*
function.A solution
The solution I had in mind would be to add a
strictRegistration
option to the input configuration, which scopes theStepRegistry
for each created instance returned bycreateBdd
?The text was updated successfully, but these errors were encountered: