diff --git a/CHANGELOG.md b/CHANGELOG.md index e66ef162..f857d437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. - Report resolved configuration correctly, fixes [#951](https://github.com/badeball/cypress-cucumber-preprocessor/issues/951). +- Visualize hook filters properly, fixes [#922](https://github.com/badeball/cypress-cucumber-preprocessor/issues/922). + ## v16.0.3 - Update dependency on `@badeball/cypress-configuration`, fixing an issue where specs in node_modules weren't ignored. diff --git a/features/issues/922.feature b/features/issues/922.feature new file mode 100644 index 00000000..ef9a0162 --- /dev/null +++ b/features/issues/922.feature @@ -0,0 +1,22 @@ +# https://github.com/badeball/cypress-cucumber-preprocessor/issues/946 + +Feature: visualizing hook with filter + Scenario: visualizing hook with filter + Given a file named "cypress/e2e/a.feature" with: + """ + @foo + Feature: a feature + Scenario: a scenario + Given a step + """ + And a file named "cypress/support/step_definitions/steps.js" with: + """ + const { Before, Given } = require("@badeball/cypress-cucumber-preprocessor"); + Before(() => {}) + Before({ tags: "@foo or @bar" }, () => {}) + Given("a step", function() { + // TODO: figure out how to query Cypress' own UI, if at all possible. + }) + """ + When I run cypress + Then it passes diff --git a/lib/browser-runtime.ts b/lib/browser-runtime.ts index 705e5295..8e4ee13e 100644 --- a/lib/browser-runtime.ts +++ b/lib/browser-runtime.ts @@ -407,6 +407,7 @@ function createPickle( runStepWithLogGroup({ fn: () => registry.runHook(this, hook), keyword: hook.keyword, + text: hook.tags, }); return cy.wrap(start, { log: false }); diff --git a/lib/registry.ts b/lib/registry.ts index 27141a16..246dbaad 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -41,6 +41,7 @@ export type HookKeyword = "Before" | "After"; export interface IHook { id: string; + tags?: string; node: ReturnType; implementation: IHookBody; keyword: HookKeyword; @@ -57,6 +58,7 @@ function parseHookArguments( ): IHook { return { id: uuid(), + tags: options.tags, node: options.tags ? parse(options.tags) : noopNode, implementation: fn, keyword,