-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Current behavior
When users run cypress open
with @cypress/grep
where filters are applied in the environment variables and matches a test in Studio, we cannot load the test content and show an error.
Workaround
✅ Remove any filtering during cypress open
- so remove the environment variables that are filtering tests in @cypress/grep
- these could be in CLI args or the configFile.

The issue isn't that we're looking for the wrong function name, but that the invocation details are off when cypress grep is active. For example, if we have a test that runs with grep, we get something like this for invocationDetails in the cypress app state
{
"function": "itGrep",
"fileUrl": "https://example.cypress.io/__cypress/tests?p=cypress/support/e2e.js",
"originalFile": "[webpack://cypress-test-tiny/./node_modules/@cypress/grep/src/support.js](webpack://cypress-test-tiny/node_modules/@cypress/grep/src/support.js)",
"relativeFile": "node_modules/@cypress/grep/src/support.js",
"absoluteFile": "/Users/adams/projects/cypress-test-tiny/node_modules/@cypress/grep/src/support.js",
"line": 126,
"column": 0,
"whitespace": " ",
"stack": "Error\n at itGrep (https://example.cypress.io/__cypress/tests?p=cypress/support/e2e.js:391:14)\n at Suite.eval (https://example.cypress.io/__cypress/tests?p=cypress/e2e/spec.cy.js:23:3)\n at Object.create (cypress:///../driver/node_modules/mocha/lib/interfaces/common.js:141:19)\n at context.describe.context.context (cypress:///../driver/node_modules/mocha/lib/interfaces/bdd.js:42:27)\n at createRunnable (cypress:///../driver/src/cypress/mocha.ts:126:31)"
}
so the line number of 126, as well as the file paths are wrong, so we can't retrieve the test block from this information. We need to get the stack trace that includes the line in the spec file rather than from the support file in cypress/grep
Desired behavior
Display the test content in Studio for users using @cypress/grep
in open mode.
Test code to reproduce
- Follow the instructions in the
@cypress/grep
docs to install and configure the package. - There are a bunch of ways to do this but I set up a test that used a tag. For example
it("works", { tags: ["@smoke"] }, () => {
cy.visit("https://example.cypress.io");
});
- Run Cypress with a grep variable configured. Again, there are a bunch of different ones, but if you used the tag above, run Cypress with the argument
--env grepTags=@smoke
.
Cypress Version
15.0.0