cypress-grep not working for me using Typescript
chinkjieh opened this issue ยท 6 comments
I ran DEBUG=cypress-grep cypress run --spec cypress/integration/test.spec.ts --env grep=zebra
logs
cypress-grep: tests with "zebra" in their names
cypress-grep Cypress config env object: { grep: 'zebra' } +0ms
cypress-grep plugin version 2.13.1 +2ms
test.spec.ts
describe('test', { tags: 'spectag' }, () => {
before(() => {
cy.log('hello');
});
it('tag1', { tags: 'tag1' }, () => {
cy.log('tag1');
});
it('tag2', { tags: 'tag2' }, () => {
cy.log('tag2');
});
it('tag1tag2', { tags: ['tag1', 'tag2'] }, () => {
cy.log('tag1tag2');
});
});
Outcome: spec with all 3 it()
ran with no filtering performed when no test should be running cause of grep=zebra
tried grepTag=tag1
and all it()
ran too.
I installed "cypress-grep": "^2.13.1"
import 'cypress-grep';
in cypress/support/index.ts
import * as cypressGrep from 'cypress-grep/src/plugin';
module.exports = (on, config) => {
return cypressGrep(config);
};
in cypress/plugins/index.js
{
"compilerOptions": {
"allowJs": true,
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "cypress-grep"]
},
"include": ["**/*.ts"]
}
in tsconfig.json
npm ls cypress-grep
shows me cypress-grep@2.13.1
correctly
Please help let me know if I m missing anything here. Thank you in advance!
Check the install section again
yes i did but i m using typescript so I cant do require
pardon me.
I have updated it to be clear in both cases https://github.com/cypress-io/cypress-grep#install
thank you for the prompt reply but
// if you want to use the "import" keyword
import registerCypressGrep from 'cypress-grep'
registerCypressGrep()
I followed your docs the install section and got this
File '/node_modules/cypress-grep/src/index.d.ts' is not a module.
Likewise, the new installation instructions do not work for me.
Reverting to:
require('cypress-grep')()
Seems to work. Also on a TS project, though I assume you need esModuleInterop: true
in your tsconfig.json
thank you for the prompt reply but
// if you want to use the "import" keyword import registerCypressGrep from 'cypress-grep' registerCypressGrep()
I followed your docs the install section and got this
File '/node_modules/cypress-grep/src/index.d.ts' is not a module.
Why is this issue closed? This still happens.