Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: badeball/cypress-cucumber-preprocessor
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v20.0.1
Choose a base ref
...
head repository: badeball/cypress-cucumber-preprocessor
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v20.0.2
Choose a head ref

Commits on Feb 12, 2024

  1. Fix typo.

    asashour authored Feb 12, 2024
    Copy the full SHA
    b6370ae View commit details
  2. Merge pull request #1151 from asashour/patch-1

    Fix typo.
    badeball authored Feb 12, 2024
    Copy the full SHA
    875ebc7 View commit details
  3. Revert "Fix typo."

    badeball authored Feb 12, 2024
    Copy the full SHA
    e8886b8 View commit details
  4. Merge pull request #1153 from badeball/revert-1151-patch-1

    Revert "Fix typo."
    badeball authored Feb 12, 2024
    Copy the full SHA
    58a561d View commit details
  5. Fix usually.

    asashour committed Feb 12, 2024
    Copy the full SHA
    f60f8c2 View commit details
  6. Merge pull request #1154 from asashour/usually

    Fix tests.
    badeball authored Feb 12, 2024
    Copy the full SHA
    5e5580b View commit details

Commits on Feb 20, 2024

  1. Copy the full SHA
    f83f338 View commit details

Commits on Feb 22, 2024

  1. Copy the full SHA
    ffc2246 View commit details
  2. Copy the full SHA
    0f1b16c View commit details
  3. Copy the full SHA
    a023012 View commit details
  4. Copy the full SHA
    cfe822c View commit details
  5. Prettier

    mallison committed Feb 22, 2024
    Copy the full SHA
    1569aed View commit details

Commits on Feb 23, 2024

  1. Copy the full SHA
    a6746ed View commit details
  2. Copy the full SHA
    e0436a2 View commit details
  3. Copy the full SHA
    5cde757 View commit details
  4. fmt

    mallison committed Feb 23, 2024
    Copy the full SHA
    99e9df3 View commit details

Commits on Feb 29, 2024

  1. Copy the full SHA
    e8893bf View commit details
  2. FMT!

    mallison committed Feb 29, 2024
    Copy the full SHA
    3e3b311 View commit details

Commits on Mar 1, 2024

  1. Add support for skipped / pending scenario hooks

    This fixes #1159 [1].
    
    [1] #1159
    badeball committed Mar 1, 2024
    Copy the full SHA
    d56a503 View commit details
  2. Merge branch 'suite-level-test-configuration-mallison'

    This fixes #1158 [1].
    
    [1] #1158
    badeball committed Mar 1, 2024
    Copy the full SHA
    58003f0 View commit details
  3. Copy the full SHA
    04a1cc8 View commit details
  4. Copy the full SHA
    302df59 View commit details
  5. Replace if with assert

    This should never be absent.
    badeball committed Mar 1, 2024
    Copy the full SHA
    d495950 View commit details
  6. Change return-type of tagToCypressOptions

    This is to better reflect the fact that it returns a single option and
    not a collection of them.
    badeball committed Mar 1, 2024
    Copy the full SHA
    ce73140 View commit details
  7. Copy the full SHA
    d1130c5 View commit details
  8. Re-word configuration error messages

    This now corresponds more closely to the original error.
    badeball committed Mar 1, 2024
    Copy the full SHA
    8d6b7e1 View commit details
  9. Copy the full SHA
    d0e86ab View commit details

Commits on Mar 3, 2024

  1. Upgrade to actions/cache@v4

    badeball committed Mar 3, 2024
    Copy the full SHA
    490214f View commit details
  2. v20.0.2

    badeball committed Mar 3, 2024
    Copy the full SHA
    145dde3 View commit details
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-matrix
name: Prepare
run: echo "matrix=$(node -p "JSON.stringify(require('./package.json').peerDependencies['cypress'].split(' || '))")" >> $GITHUB_OUTPUT
@@ -25,14 +25,14 @@ jobs:
cypress-version: ${{fromJson(needs.prepare-versions.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux@${{ matrix.cypress-version }}
- name: Cache Cypress binaries
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-linux@${{ matrix.cypress-version }}
@@ -59,14 +59,14 @@ jobs:
CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cypress
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .npm
key: npm-windows
- name: Cache Cypress binaries
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .cypress
key: cypress-windows
14 changes: 7 additions & 7 deletions .github/workflows/examples-branch.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-matrix
name: Prepare
run: echo "matrix=$(node -p "JSON.stringify(fs.readdirSync('examples').filter(f => f !== 'readme.md'))")" >> $GITHUB_OUTPUT
@@ -28,14 +28,14 @@ jobs:
image: cypress/base:20.5.0
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux@latest
- name: Cache Cypress binaries
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-linux@latest
@@ -70,14 +70,14 @@ jobs:
NPM_CONFIG_PACKAGE_LOCK: "false"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: npm@${{ matrix.example }}
- name: Cache Cypress binaries
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-examples
8 changes: 4 additions & 4 deletions .github/workflows/examples-master.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-matrix
name: Prepare
run: echo "matrix=$(node -p "JSON.stringify(fs.readdirSync('examples').filter(f => f !== 'readme.md'))")" >> $GITHUB_OUTPUT
@@ -34,14 +34,14 @@ jobs:
NPM_CONFIG_PACKAGE_LOCK: "false"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: npm@${{ matrix.example }}
- name: Cache Cypress binaries
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-examples
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## v20.0.2

- Add support for skipped / pending scenario hooks, fixes [#1159](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1159).

- Add support for suite-level test configuration, fixes [#1158](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1158).

## v20.0.1

- Handle more corner cases related to reload-behavior, fixes [#1142](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1142).
5 changes: 5 additions & 0 deletions docs/cucumber-basics.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
- [Hooks](#hooks)
- [Run hooks](#run-hooks)
- [Scenario hooks](#scenario-hooks)
- [Pending / skipped scenario hooks](#pending--skipped-scenario-hooks)
- [Step hooks](#step-hooks)
- [Hook ordering](#hook-ordering)
- [Named hooks](#named-hooks)
@@ -188,6 +189,10 @@ Before(function ({ pickle, gherkinDocument, testCaseStartedId }) {
});
```

### Pending / skipped scenario hooks

Scenario hooks can be made pending or skipped similarly to steps, as explained above, by returning `"pending"` or `"skipped"`, respectively. Both will halt the execution and Cypress will report the test as "skipped".

## Step hooks

`BeforeStep()` and `AfterStep()` are hooks invoked before and after each step, respectively. These too can be selected to conditionally run based on the tags of each scenario, as shown below.
39 changes: 39 additions & 0 deletions features/pending_scenario_hooks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Feature: pending scenario hooks

Scenario: pending Before() hook
Given a file named "cypress/e2e/a.feature" with:
"""
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(() => {
return "pending"
})
Given("a step", function() {})
"""
When I run cypress
Then it passes
And it should appear to have skipped the scenario "a scenario"

Scenario: pending After() hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { After, Given } = require("@badeball/cypress-cucumber-preprocessor")
After(() => {
return "pending"
})
Given("a step", function() {})
"""
When I run cypress
Then it passes
And it should appear to have skipped the scenario "a scenario"
2 changes: 1 addition & 1 deletion features/setup.feature
Original file line number Diff line number Diff line change
@@ -30,5 +30,5 @@ Feature: setup
Then it fails
And the output should contain
"""
Missing preprocessor event handlers (this usally means you've not invoked `addCucumberPreprocessorPlugin()` or not returned the config object in `setupNodeEvents()`)
Missing preprocessor event handlers (this usually means you've not invoked `addCucumberPreprocessorPlugin()` or not returned the config object in `setupNodeEvents()`)
"""
39 changes: 39 additions & 0 deletions features/skipped_scenario_hooks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Feature: skipped scenario hooks

Scenario: skipped Before() hook
Given a file named "cypress/e2e/a.feature" with:
"""
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(() => {
return "skipped"
})
Given("a step", function() {})
"""
When I run cypress
Then it passes
And it should appear to have skipped the scenario "a scenario"

Scenario: skipped After() hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { After, Given } = require("@badeball/cypress-cucumber-preprocessor")
After(() => {
return "skipped"
})
Given("a step", function() {})
"""
When I run cypress
Then it passes
And it should appear to have skipped the scenario "a scenario"
135 changes: 135 additions & 0 deletions features/suite_only_options.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
@cypress>=12
Feature: suite only options

Background:
Given additional Cypress configuration
"""
{
"e2e": {
"testIsolation": true
}
}
"""

Rule: testIsolation is only applicable for Feature / Rule

Scenario: Configuring testIsolation on a Feature
Given a file named "cypress/e2e/a.feature" with:
"""
@testIsolation(false)
Feature: a feature
Scenario: a scenario
Given a step
Scenario: another scenario
Then another step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", () => {
cy.get("body").invoke('html', 'Hello world')
});
Given("another step", () => {
cy.contains("Hello world").should("exist");
});
"""
When I run cypress
Then it passes

Scenario: Configuring testIsolation on a Rule
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@testIsolation(false)
Rule: a rule
Scenario: a scenario
Given a step
Scenario: another scenario
Then another step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", () => {
cy.get("body").invoke('html', 'Hello world')
});
Given("another step", () => {
cy.contains("Hello world").should("exist");
});
"""
When I run cypress
Then it passes

Scenario: Configuring testIsolation on a Scenario
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@testIsolation(false)
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", () => {
cy.get("body").invoke('html', 'Hello world')
});
"""
When I run cypress
Then it fails
And the output should contain
"""
The `testIsolation` configuration can only be overridden from a suite-level override (in Cucumber-terms this means on a Feature or Rule).
"""

Scenario: Configuring testIsolation on a Scenario Outline
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@testIsolation(false)
Scenario Outline: a scenario
Given a step
Examples:
| foo |
| bar |
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", () => {
cy.get("body").invoke('html', 'Hello world')
});
"""
When I run cypress
Then it fails
And the output should contain
"""
The `testIsolation` configuration can only be overridden from a suite-level override (in Cucumber-terms this means on a Feature or Rule).
"""

Scenario: Configuring testIsolation on Examples
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario Outline: a scenario
Given a step
@testIsolation(false)
Examples:
| foo |
| bar |
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", () => {
cy.get("body").invoke('html', 'Hello world')
});
"""
When I run cypress
Then it fails
And the output should contain
"""
The `testIsolation` configuration can only be overridden from a suite-level override (in Cucumber-terms this means on a Feature or Rule).
"""
13 changes: 11 additions & 2 deletions features/support/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import { promises as fs } from "fs";
import assert from "assert";
import { version as cypressVersion } from "cypress/package.json";
import { promises as fs } from "fs";
import path from "path";

export async function writeFile(filePath: string, fileContent: string) {
await fs.mkdir(path.dirname(filePath), { recursive: true });
@@ -106,3 +107,11 @@ export function stringToNdJson(content: string) {
export function ndJsonToString(ndjson: any) {
return ndjson.map((o: any) => JSON.stringify(o)).join("\n") + "\n";
}

export function isPost12() {
return parseInt(cypressVersion.split(".")[0], 10) >= 12;
}

export function isPre12() {
return !isPost12();
}
Loading