Skip to content

Commit

Permalink
Visualize hook filter if any
Browse files Browse the repository at this point in the history
This fixes #922.
  • Loading branch information
badeball committed Apr 30, 2023
1 parent 8615f8a commit 870207d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file.

- Report resolved configuration correctly, [#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.
Expand Down
22 changes: 22 additions & 0 deletions features/issues/922.feature
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/browser-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ function createPickle(
runStepWithLogGroup({
fn: () => registry.runHook(this, hook),
keyword: hook.keyword,
text: hook.tags,
});

return cy.wrap(start, { log: false });
Expand Down
2 changes: 2 additions & 0 deletions lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type HookKeyword = "Before" | "After";

export interface IHook {
id: string;
tags?: string;
node: ReturnType<typeof parse>;
implementation: IHookBody;
keyword: HookKeyword;
Expand All @@ -57,6 +58,7 @@ function parseHookArguments(
): IHook {
return {
id: uuid(),
tags: options.tags,
node: options.tags ? parse(options.tags) : noopNode,
implementation: fn,
keyword,
Expand Down

0 comments on commit 870207d

Please sign in to comment.