cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.84k stars 3.17k forks source link

@cypress/grep grepTags Typescript issue #28458

Closed catkav closed 2 weeks ago

catkav commented 10 months ago

Current behavior

When using grepTags in it block I'm seeing the following error:

Argument of type '{ tags: string; }' is not assignable to parameter of type 'ProvidesCallback'. Object literal may only specify known properties, and 'tags' does not exist in type 'ProvidesCallback'.

I've added "@cypress/grep" to "types" in my tsconfig.json file and I've added /// <reference types="@cypress/grep" /> to the top of my index.d.ts file like was suggested here https://github.com/cypress-io/cypress-grep/issues/166#issuecomment-1353558775

Desired behavior

Currently I've added a comment to ignore the error //@ts-expect-error TS(2345): Argument of type '{ tags: string; }' is not assignable to parameter of type 'ProvidesCallback' However I want to tag a lot of tests and I don't want to have to comment them all, so looking for a way to resolve the error

Any help appreciated

Test code to reproduce

it('should test something', { tags: '@smoke' }, () => {
// test
});

@cypress/grep version: 4.0.1

Cypress Version

12.17.2

Node version

v18.16.1

Operating System

macOS 13.6.1

Debug Logs

No response

Other

No response

rudreshtrivedi commented 10 months ago

Did you update config.ts file ??

// cypress.config.ts
{
  e2e: {
    setupNodeEvents(on, config) {
      cypressGrepPlugin(on, config);
            on('task', {
                grep(config) {
                    return cypressGrepPlugin(on, config);
                },
            });
            return config;    },
  },
},

Please follow https://github.com/cypress-io/cypress/tree/develop/npm/grep#install

catkav commented 10 months ago

Did you update config.ts file ??

// cypress.config.js
{
  e2e: {
    setupNodeEvents(on, config) {
      require('@cypress/grep/src/plugin')(config);
      return config;
    },
  }
}

Please follow https://github.com/cypress-io/cypress/tree/develop/npm/grep#install

Just tried there and still seeing the Typescript error

rudreshtrivedi commented 10 months ago

Try again, I have updated exact config for typescript, I would recommend to restart TS server

catkav commented 10 months ago

Tried again and restarted TS server (also tried restarting VSCode), but still seeing the error

nemanjaglumac commented 7 months ago

@catkav I've had the same issue until I realized cypress grep was one major version behind. Please upgrade it to the latest version (it should be major version 4) and try again.

After the upgrade, just adding @cypress/grep to the tsconfig solved the issue.

cypress-app-bot commented 1 month ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 2 weeks ago

This issue has been closed due to inactivity.