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

fix(grep): references to cypress-grep #26108

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions npm/grep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ All other tests will be marked pending, see why in the [Cypress test statuses](h

If you have multiple spec files, all specs will be loaded, and every test will be filtered the same way, since the grep is run-time operation and cannot eliminate the spec files without loading them. If you want to run only specific tests, use the built-in [--spec](https://on.cypress.io/command-line#cypress-run-spec-lt-spec-gt) CLI argument.

Watch the video [intro to cypress-grep plugin](https://www.youtube.com/watch?v=HS-Px-Sghd8)
Watch the video [intro to @cypress/grep plugin](https://www.youtube.com/watch?v=HS-Px-Sghd8)

Table of Contents

Expand Down Expand Up @@ -499,18 +499,18 @@ Cypress.grep('hello', '@smoke', 10)

## Debugging

When debugging a problem, first make sure you are using the expected version of this plugin, as some features might be only available in the [later releases](https://github.com/cypress-io/cypress-grep/releases).
When debugging a problem, first make sure you are using the expected version of this plugin, as some features might be only available in the [later releases](https://www.npmjs.com/package/@cypress/grep?activeTab=versions).

```
# get the cypress-grep version using NPM
$ npm ls cypress-grep
# get the @cypress/grep version using NPM
$ npm ls @cypress/grep
...
└── cypress-[email protected]
# get the cypress-grep version using Yarn
$ yarn why cypress-grep
└── @cypress/[email protected]
# get the @cypress/grep version using Yarn
$ yarn why @cypress/grep
...
=> Found "cypress-grep@2.10.1"
info Has been hoisted to "cypress-grep"
=> Found "@cypress/grep@3.1.0"
info Has been hoisted to "@cypress/grep"
info This module exists because it's specified in "devDependencies".
...
```
Expand All @@ -531,30 +531,30 @@ This module uses [debug](https://github.com/visionmedia/debug#readme) to log ver

### Debugging in the plugin

Start Cypress with the environment variable `DEBUG=cypress-grep`. You will see a few messages from this plugin in the terminal output:
Start Cypress with the environment variable `DEBUG=@cypress/grep`. You will see a few messages from this plugin in the terminal output:

```
$ DEBUG=cypress-grep npx cypress run --env grep=works,grepFilterSpecs=true
cypress-grep: tests with "works" in their names
cypress-grep: filtering specs using "works" in the title
cypress-grep Cypress config env object: { grep: 'works', grepFilterSpecs: true }
$ DEBUG=@cypress/grep npx cypress run --env grep=works,grepFilterSpecs=true
@cypress/grep: tests with "works" in their names
@cypress/grep: filtering specs using "works" in the title
@cypress/grep Cypress config env object: { grep: 'works', grepFilterSpecs: true }
...
cypress-grep found 1 spec files +5ms
cypress-grep [ 'spec.js' ] +0ms
cypress-grep spec file spec.js +5ms
cypress-grep suite and test names: [ 'hello world', 'works', 'works 2 @tag1',
@cypress/grep found 1 spec files +5ms
@cypress/grep [ 'spec.js' ] +0ms
@cypress/grep spec file spec.js +5ms
@cypress/grep suite and test names: [ 'hello world', 'works', 'works 2 @tag1',
'works 2 @tag1 @tag2', 'works @tag2' ] +0ms
cypress-grep found "works" in 1 specs +0ms
cypress-grep [ 'spec.js' ] +0ms
@cypress/grep found "works" in 1 specs +0ms
@cypress/grep [ 'spec.js' ] +0ms
```

### Debugging in the browser

To enable debug console messages in the browser, from the DevTools console set `localStorage.debug='cypress-grep'` and run the tests again.
To enable debug console messages in the browser, from the DevTools console set `localStorage.debug='@cypress/grep'` and run the tests again.

![Debug messages](./images/debug.png)

To see how to debug this plugin, watch the video [Debug cypress-grep Plugin](https://youtu.be/4YMAERddHYA).
To see how to debug this plugin, watch the video [Debug @cypress/grep Plugin](https://youtu.be/4YMAERddHYA).

## Examples

Expand Down Expand Up @@ -595,11 +595,11 @@ The above scenario was confusing - did you want to find all tests with title con

### from v2 to v3

Version >= 3 of cypress-grep _only_ supports Cypress >= 10.
Version >= 3 of @cypress/grep _only_ supports Cypress >= 10.

## Small Print

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet /
[open issue](https://github.com/cypress-io/cypress/issues) on Github
[open issue](https://github.com/cypress-io/cypress/issues) on Github.
20 changes: 10 additions & 10 deletions npm/grep/src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const debug = require('debug')('cypress-grep')
const debug = require('debug')('@cypress/grep')
const globby = require('globby')
const { getTestNames } = require('find-test-names')
const fs = require('fs')
const { version } = require('../package.json')
const { parseGrep, shouldTestRun } = require('./utils')

/**
* Prints the cypress-grep environment values if any.
* Prints the @cypress/grep environment values if any.
* @param {Cypress.ConfigOptions} config
*/
function cypressGrepPlugin (config) {
Expand All @@ -18,23 +18,23 @@ function cypressGrepPlugin (config) {

if (!config.specPattern) {
throw new Error(
'Incompatible versions detected, cypress-grep 3.0.0+ requires Cypress 10.0.0+',
'Incompatible versions detected, @cypress/grep 3.0.0+ requires Cypress 10.0.0+',
)
}

debug('cypress-grep plugin version %s', version)
debug('@cypress/grep plugin version %s', version)
debug('Cypress config env object: %o', env)

const grep = env.grep ? String(env.grep) : undefined

if (grep) {
console.log('cypress-grep: tests with "%s" in their names', grep.trim())
console.log('@cypress/grep: tests with "%s" in their names', grep.trim())
}

const grepTags = env.grepTags || env['grep-tags']

if (grepTags) {
console.log('cypress-grep: filtering using tag(s) "%s"', grepTags)
console.log('@cypress/grep: filtering using tag(s) "%s"', grepTags)
const parsedGrep = parseGrep(null, grepTags)

debug('parsed grep tags %o', parsedGrep.tags)
Expand All @@ -43,19 +43,19 @@ function cypressGrepPlugin (config) {
const grepBurn = env.grepBurn || env['grep-burn'] || env.burn

if (grepBurn) {
console.log('cypress-grep: running filtered tests %d times', grepBurn)
console.log('@cypress/grep: running filtered tests %d times', grepBurn)
}

const grepUntagged = env.grepUntagged || env['grep-untagged']

if (grepUntagged) {
console.log('cypress-grep: running untagged tests')
console.log('@cypress/grep: running untagged tests')
}

const omitFiltered = env.grepOmitFiltered || env['grep-omit-filtered']

if (omitFiltered) {
console.log('cypress-grep: will omit filtered tests')
console.log('@cypress/grep: will omit filtered tests')
}

const { specPattern, excludeSpecPattern } = config
Expand All @@ -78,7 +78,7 @@ function cypressGrepPlugin (config) {
let greppedSpecs = []

if (grep) {
console.log('cypress-grep: filtering specs using "%s" in the title', grep)
console.log('@cypress/grep: filtering specs using "%s" in the title', grep)
const parsedGrep = parseGrep(grep)

debug('parsed grep %o', parsedGrep)
Expand Down
6 changes: 3 additions & 3 deletions npm/grep/src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const _describe = describe

/**
* Wraps the "it" and "describe" functions that support tags.
* @see https://github.com/cypress-io/cypress-grep
* @see https://github.com/cypress-io/cypress/tree/develop/npm/grep
*/
function cypressGrep () {
/** @type {string} Part of the test title go grep */
Expand Down Expand Up @@ -63,7 +63,7 @@ function cypressGrep () {
// prevent multiple registrations
// https://github.com/cypress-io/cypress-grep/issues/59
if (it.name === 'itGrep') {
debug('already registered cypress-grep')
debug('already registered @cypress/grep')

return
}
Expand Down Expand Up @@ -228,7 +228,7 @@ if (!Cypress.grep) {
* // remove all current grep settings
* // and run all tests
* Cypress.grep()
* @see "Grep from DevTools console" https://github.com/cypress-io/cypress-grep#devtools-console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system-tests/projects/nx-monorepo was this file added on accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

* @see "Grep from DevTools console" https://github.com/cypress-io/cypress/tree/develop/npm/grep#devtools-console
*/
Cypress.grep = function grep (grep, tags, burn) {
Cypress.env('grep', grep)
Expand Down