Skip to content

@focus not working as expectedΒ #4

Open
@kpturner

Description

@kpturner

I logged this issue before but did not provide enough detail about how to replicate it.

Firstly my understanding of the @Focus tag is that only that scenario will run and all other scenarios in all other features will not.

Taking this repo as an example is not ideal as it does not have enough features/scenarios. So I deleted the features in this repo and copied in the features from the original repo: https://github.com/TheBrainFamily/cypress-cucumber-preprocessor

So I now have:

common
news
socialNetworks
All.features

I then renamed all the .js files to .ts.

I then included a tsconfig.json file in the root like this:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "types": ["node", "cypress"],
        "moduleResolution": "node",
        "lib": ["es2016", "dom", "dom.iterable"],
        "downlevelIteration": true,
        "sourceMap": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noImplicitReturns": true,
        "esModuleInterop": true,
        "strict": false
    },
    "exclude": [
        "node_modules"
    ],
    "include": [
        "cypress/**/*.ts"
    ]
}

I then added a cypress/support/index.d.ts file like this:

// in cypress/support/index.d.ts
// load type definitions that come with Cypress module
/// <reference types="cypress" />

My package.json file ensured that we have the latest stuff:

{
  "name": "cypress-cucumber-typescript-example",
  "version": "1.0.0",
  "description": "Example of how to use Cypress with Cucumber and TypeScript",
  "main": "index.js",
  "scripts": {
    "test": "npx cypress run --spec \"**/*.features\""
  },
  "author": "Lukasz Gandecki",
  "license": "ISC",
  "dependencies": {
    "cypress": "^4.9.0",
    "cypress-cucumber-preprocessor": "^2.5.2",
    "tsify": "^4.0.1",
    "typescript": "^3.4.5"
  },
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true
  }
}

I then added this line to the top of cypress/integration/common/globalBefore.ts

/// <reference path="../../support/index.d.ts" />

Ran npm i to install everything.

I want to focus only on the first Google test like this:

Feature: The Google

  I want to open Google page

  @focus
  Scenario: Opening a Google network page
    Given I open Google page
    Then I see "Google" in the title

  Scenario: Different kind of opening
    Given I kinda open Google page
    Then I am very happy

When I run npm run test I find that
Scenario: Opening a Google network page runs
Scenario: Different kind of opening is pending
so far so good....however, all the other tests in news and socialNetworks also run

This seems wrong to me. I would only expect one scenario to run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions