Skip to content

Commit 7a94766

Browse files
committed
Add error for suites without callback functions
1 parent 0a87734 commit 7a94766

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/driver/src/cy/errors.coffee

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ $dom = require("../dom")
22
$utils = require("../cypress/utils")
33

44
crossOriginScriptRe = /^script error/i
5+
describeCallbackRe = /context\.describe\.context\.context/i
56

67
create = (state, config, log) ->
78
commandErr = (err) ->
@@ -49,7 +50,10 @@ create = (state, config, log) ->
4950
when "app" then "uncaught.fromApp"
5051
when "spec" then "uncaught.fromSpec"
5152

52-
err = $utils.appendErrMsg(err, $utils.errMessageByPath(suffixMsg))
53+
if describeCallbackRe.test(err.stack)
54+
err = $utils.appendErrMsg(err, $utils.errMessageByPath("uncaught.no_suite_callback"))
55+
else
56+
err = $utils.appendErrMsg(err, $utils.errMessageByPath(suffixMsg))
5357

5458
err.onFail = ->
5559
if l = current and current.getLastLog()

packages/driver/src/cypress/error_messages.coffee

+5
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,11 @@ module.exports = {
793793
wrong_type: "#{cmd('type')} can only accept a String or Number. You passed in: '{{chars}}'"
794794

795795
uncaught:
796+
no_suite_callback: """
797+
Cypress detected a suite, such as a 'describe' or 'context' block, without a callback function.
798+
799+
Provide a callback function or intentionally skip the suite or this test to run.
800+
"""
796801
cross_origin_script: """
797802
Script error.
798803

0 commit comments

Comments
 (0)