Skip to content
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

@focus not working as expected #4

Open
kpturner opened this issue Jul 16, 2020 · 0 comments
Open

@focus not working as expected #4

kpturner opened this issue Jul 16, 2020 · 0 comments

Comments

@kpturner
Copy link

kpturner commented Jul 16, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant