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

[WIP] Add error for suites without callback functions #3651

Closed
wants to merge 11 commits into from
Closed
3 changes: 3 additions & 0 deletions packages/driver/src/cypress/error_messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,9 @@ module.exports = {
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
"""

suite_without_callback: (suiteTitle) ->
return "Suite '#{suiteTitle}' was defined but no callback was supplied. Supply a callback or explicitly skip the suite."

viewport:
bad_args: "#{cmd('viewport')} can only accept a string preset or a width and height as numbers."
dimensions_out_of_range: "#{cmd('viewport')} width and height must be at least 0px."
Expand Down
308 changes: 308 additions & 0 deletions packages/server/__snapshots__/6_uncaught_spec_errors_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,311 @@ exports['e2e uncaught errors / failing5'] = `


`

exports['e2e uncaught errors failing6 1'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (uncaught_missing_suite_callback.js) │
│ Searched: cypress/integration/uncaught_missing_suite_callback.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: uncaught_missing_suite_callback.js... (1 of 1)


1) An uncaught error was detected outside of a test

0 passing
1 failing

1) An uncaught error was detected outside of a test:
Uncaught TypeError: Cannot read property 'call' of undefined

This error originated from your test code, not from Cypress.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Suite 'foo' was defined but no callback was supplied. Supply a callback or explicitly skip the suite.
at stack trace line




(Results)

┌──────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: uncaught_missing_suite_callback.js │
└──────────────────────────────────────────────────┘


(Screenshots)

- /foo/bar/.projects/e2e/cypress/screenshots/uncaught_missing_suite_callback.js/An uncaught error was detected outside of a test (failed).png (1280x720)


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ uncaught_missing_suite_callback.js XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 1 - 1 - -


`

exports['e2e uncaught errors failing7 1'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (uncaught_missing_suite_callback_empty_suite.js) │
│ Searched: cypress/integration/uncaught_missing_suite_callback_empty_suite.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: uncaught_missing_suite_callback_empty_suite.js... (1 of 1)


1) An uncaught error was detected outside of a test

0 passing
1 failing

1) An uncaught error was detected outside of a test:
Uncaught TypeError: Cannot read property 'call' of undefined

This error originated from your test code, not from Cypress.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Suite 'testing2' was defined but no callback was supplied. Supply a callback or explicitly skip the suite.
at stack trace line




(Results)

┌──────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: uncaught_missing_suite_callback_empty_suite.js │
└──────────────────────────────────────────────────────────────┘


(Screenshots)

- /foo/bar/.projects/e2e/cypress/screenshots/uncaught_missing_suite_callback_empty_suite.js/An uncaught error was detected outside of a test (failed).png (1280x720)


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ uncaught_missing_suite_callback_empt… XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 1 - 1 - -


`

exports['e2e uncaught errors failing8 1'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (uncaught_missing_suite_callback_empty_suite.js) │
│ Searched: cypress/integration/uncaught_missing_suite_callback_empty_suite.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: uncaught_missing_suite_callback_empty_suite.js... (1 of 1)


1) An uncaught error was detected outside of a test

0 passing
1 failing

1) An uncaught error was detected outside of a test:
Uncaught TypeError: Cannot read property 'call' of undefined

This error originated from your test code, not from Cypress.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Suite 'testing2' was defined but no callback was supplied. Supply a callback or explicitly skip the suite.
at stack trace line




(Results)

┌──────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: uncaught_missing_suite_callback_empty_suite.js │
└──────────────────────────────────────────────────────────────┘


(Screenshots)

- /foo/bar/.projects/e2e/cypress/screenshots/uncaught_missing_suite_callback_empty_suite.js/An uncaught error was detected outside of a test (failed).png (1280x720)


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ uncaught_missing_suite_callback_empt… XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 1 - 1 - -


`

exports['e2e uncaught errors failing9 1'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (uncaught_missing_suite_callback_type_error.js) │
│ Searched: cypress/integration/uncaught_missing_suite_callback_type_error.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: uncaught_missing_suite_callback_type_error.js... (1 of 1)


1) An uncaught error was detected outside of a test

0 passing
1 failing

1) An uncaught error was detected outside of a test:
Uncaught TypeError: fn.call is not a function

This error originated from your test code, not from Cypress.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Suite 'testing' was defined but no callback was supplied. Supply a callback or explicitly skip the suite.
at stack trace line




(Results)

┌─────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: uncaught_missing_suite_callback_type_error.js │
└─────────────────────────────────────────────────────────────┘


(Screenshots)

- /foo/bar/.projects/e2e/cypress/screenshots/uncaught_missing_suite_callback_type_error.js/An uncaught error was detected outside of a test (failed).png (1280x720)


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ uncaught_missing_suite_callback_type… XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 1 - 1 - -


`
46 changes: 41 additions & 5 deletions packages/server/test/e2e/6_uncaught_spec_errors_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,44 @@ describe "e2e uncaught errors", ->
expectedExitCode: 1
}

e2e.it "failing5", {
spec: "caught_async_sync_test_spec.coffee"
snapshot: true
expectedExitCode: 4
}
it "failing5", ->
e2e.exec(@, {
spec: "caught_async_sync_test_spec.coffee"
snapshot: true
expectedExitCode: 4
})

it "failing6", ->
e2e.exec(@, {
spec: "uncaught_missing_suite_callback.js"
snapshot: true
expectedExitCode: 1
})

it "failing7", ->
e2e.exec(@, {
spec: "uncaught_missing_suite_callback_empty_suite.js"
snapshot: true
expectedExitCode: 1
})

it "failing8", ->
e2e.exec(@, {
spec: "uncaught_missing_suite_callback_empty_suite.js"
snapshot: true
expectedExitCode: 1
})

it "failing9", ->
e2e.exec(@, {
spec: "uncaught_missing_suite_callback_type_error.js"
snapshot: true
expectedExitCode: 1
})

it "failing9", ->
e2e.exec(@, {
spec: "uncaught_missing_suite_callback_type_error.js"
snapshot: true
expectedExitCode: 1
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
describe('foo')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

context('testing', () => { })

describe('testing2')

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

describe('testing', '123')