forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace diagnostics with a more proper dry-run
This is "more proper" in the sense that it's still executing tests an actual Cypress environments, while still being reasonably quick. This is related to #1120 [1]. This closes #1129 [2]. [1] #1120 [2] #1129
- Loading branch information
Showing
62 changed files
with
1,449 additions
and
1,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[← Back to documentation](readme.md) | ||
|
||
# Dry run | ||
|
||
Dry run is a run mode in which no steps or any type of hooks are executed. A few examples where this is useful: | ||
|
||
- Finding unused step definitions with [usage reports](usage-report.md) | ||
- Generating snippets for all undefined steps | ||
- Checking if your path, tag expression, etc. matches the scenarios you expect it to | ||
|
||
Dry run can be enabled using `dryRun`, like seen below. | ||
|
||
``` | ||
$ cypress run --env dryRun=true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[← Back to documentation](readme.md) | ||
|
||
# Source maps | ||
|
||
How to enable source maps for each bundler is shown below. | ||
|
||
## esbuild | ||
|
||
```js | ||
const { defineConfig } = require("cypress"); | ||
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor"); | ||
const { | ||
addCucumberPreprocessorPlugin, | ||
} = require("@badeball/cypress-cucumber-preprocessor"); | ||
const { | ||
createEsbuildPlugin, | ||
} = require("@badeball/cypress-cucumber-preprocessor/esbuild"); | ||
|
||
async function setupNodeEvents(on, config) { | ||
// This is required for the preprocessor to be able to generate JSON reports after each run, and more, | ||
await addCucumberPreprocessorPlugin(on, config); | ||
|
||
on( | ||
"file:preprocessor", | ||
createBundler({ | ||
plugins: [createEsbuildPlugin(config)], | ||
sourcemap: "inline" | ||
}) | ||
); | ||
|
||
// Make sure to return the config object as it might have been modified by the plugin. | ||
return config; | ||
} | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
baseUrl: "https://duckduckgo.com", | ||
specPattern: "**/*.feature", | ||
setupNodeEvents, | ||
}, | ||
}); | ||
``` | ||
|
||
## Webpack | ||
|
||
Source maps are enabled by default. | ||
|
||
## Browserify | ||
|
||
Source maps are enabled by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[← Back to documentation](readme.md) | ||
|
||
# Usage reports | ||
|
||
> :warning: This requires you to have [source maps](source-maps.md) enabled. | ||
The usage report lists your step definitions and tells you about usages in your scenarios, including the duration of each usage, and any unused steps. Here's an example of the output: | ||
|
||
``` | ||
┌───────────────────────────────────────┬──────────┬─────────────────────────────────┐ | ||
│ Pattern / Text │ Duration │ Location │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ an empty todo list │ 760.33ms │ support/steps/steps.ts:6 │ | ||
│ an empty todo list │ 820ms │ features/empty.feature:4 │ | ||
│ an empty todo list │ 761ms │ features/adding-todos.feature:4 │ | ||
│ an empty todo list │ 700ms │ features/empty.feature:4 │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ I add the todo {string} │ 432.00ms │ support/steps/steps.ts:10 │ | ||
│ I add the todo "buy some cheese" │ 432ms │ features/adding-todos.feature:5 │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ my cursor is ready to create a todo │ 53.00ms │ support/steps/steps.ts:27 │ | ||
│ my cursor is ready to create a todo │ 101ms │ features/empty.feature:10 │ | ||
│ my cursor is ready to create a todo │ 5ms │ features/adding-todos.feature:8 │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ no todos are listed │ 46.00ms │ support/steps/steps.ts:15 │ | ||
│ no todos are listed │ 46ms │ features/empty.feature:7 │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ the todos are: │ 31.00ms │ support/steps/steps.ts:21 │ | ||
│ the todos are: │ 31ms │ features/adding-todos.feature:6 │ | ||
├───────────────────────────────────────┼──────────┼─────────────────────────────────┤ | ||
│ I remove the todo {string} │ UNUSED │ support/steps/steps.ts:33 │ | ||
└───────────────────────────────────────┴──────────┴─────────────────────────────────┘ | ||
``` | ||
|
||
Usage reports can be enabled using the `usage.enabled` property. The preprocessor uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig), which means you can place configuration options in EG. `.cypress-cucumber-preprocessorrc.json` or `package.json`. An example configuration is shown below. | ||
|
||
```json | ||
{ | ||
"usage": { | ||
"enabled": true | ||
} | ||
} | ||
``` | ||
|
||
The report is outputted to stdout (your console) by default, but can be configured to be written to a file through the `usage.output` property. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.