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

feat: Add 'slowTestThreshold' and fix this.slow() inside specs #18496

Merged
merged 22 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1ff421f
Add 'slow' option to configure slow test threshold
BlueWinds Oct 5, 2021
203072f
Rename slow to slowTestThreshold; Remove --slow command line option; …
BlueWinds Oct 6, 2021
be844b2
Typo fix
BlueWinds Oct 6, 2021
1496833
Throw error on this.slow() informing users about slowTestThreshold in…
BlueWinds Oct 6, 2021
80ea0f3
Revert "Throw error on this.slow() informing users about slowTestThre…
BlueWinds Oct 6, 2021
aacfc28
Review feedback, standardizing all docs about slowTestThreshold to us…
BlueWinds Oct 7, 2021
53c2328
Rework how slowTestThreshold / _slow are passed around
BlueWinds Oct 12, 2021
c504a11
Update default slowTestThreshold to vary for testingTypes, add system…
BlueWinds Oct 13, 2021
a2784af
Update additional snapshots
BlueWinds Oct 13, 2021
30bd7ae
Change 'orange' to 'yellow' in all places for consistency
Oct 14, 2021
93bd123
Merge remote-tracking branch 'origin/develop' into issue-447-configur…
BlueWinds Oct 14, 2021
ea1f227
Allow default config to be functions; support per-test slowTestThresh…
BlueWinds Oct 20, 2021
c494687
Merge branch 'develop' into issue-447-configure-slow-test-threshold
BlueWinds Oct 20, 2021
833c1e4
Merge remote-tracking branch 'origin/develop' into issue-447-configur…
BlueWinds Oct 20, 2021
2ae591f
Update snapshots with new default value
BlueWinds Oct 21, 2021
ec9c449
Fix test for e2e -> system-tests migration
BlueWinds Oct 21, 2021
50098f0
Move slow test system test to new location
BlueWinds Oct 21, 2021
e532fc8
Minor tweak to documentation link
BlueWinds Oct 22, 2021
f3c1947
Update additional comments
BlueWinds Oct 25, 2021
d5bd2fa
Merge remote-tracking branch 'origin/develop' into issue-447-configur…
BlueWinds Oct 25, 2021
86f7f15
Remove accidentally added unified files
BlueWinds Oct 25, 2021
41a2d1a
Remove more accidentally added unification files
BlueWinds Oct 25, 2021
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
5 changes: 5 additions & 0 deletions cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"default": null,
"description": "The reporter options used. Supported options depend on the reporter. See https://on.cypress.io/reporters#Reporter-Options"
},
"slowTestThreshold": {
"type": "number",
"default": 10000,
"description": "Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold. See https://on.cypress.io/configuration#Global"
},
"testFiles": {
"type": [
"string",
Expand Down
4 changes: 4 additions & 0 deletions cli/types/cypress-npm-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ declare namespace CypressCommandLine {
* Specify mocha reporter options
*/
reporterOptions: any
/**
* Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
*/
slowTestThreshold: number
/**
* Specify the specs to run
*/
Expand Down
5 changes: 5 additions & 0 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,11 @@ declare namespace Cypress {
* @default "spec"
*/
reporterOptions: { [key: string]: any }
/**
* Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
* @default 10000
*/
slowTestThreshold: number
/**
* Whether Cypress will watch and restart tests on test file changes
* @default true
Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/cypress/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ const create = (specWindow, Cypress, config) => {

const _mocha = createMocha(specWindow)

_mocha.slow(config('slowTestThreshold'))

const _runner = getRunner(_mocha)

_mocha.suite.file = Cypress.spec.relative
Expand Down
6 changes: 5 additions & 1 deletion packages/driver/src/cypress/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TEST_BEFORE_RUN_EVENT = 'runner:test:before:run'
const TEST_AFTER_RUN_EVENT = 'runner:test:after:run'

const RUNNABLE_LOGS = 'routes agents commands hooks'.split(' ')
const RUNNABLE_PROPS = '_testConfig id order title _titlePath root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings file originalTitle invocationDetails final currentRetry retries'.split(' ')
const RUNNABLE_PROPS = '_testConfig id order title _titlePath root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings file originalTitle invocationDetails final currentRetry retries _slow'.split(' ')

const debug = debugFn('cypress:driver:runner')
const debugErrors = debugFn('cypress:driver:errors')
Expand Down Expand Up @@ -581,6 +581,10 @@ const normalize = (runnable, tests, initialTests, onRunnable, onLogsById, getRun
wrappedRunnable._testConfig = cfg
}

if (cfg.slowTestThreshold) {
runnable.slow(cfg.slowTestThreshold)
}

wrappedRunnable._titlePath = runnable.titlePath()
}

Expand Down
Loading