Skip to content

Commit

Permalink
fix: Add missing error message when req.continue is used incorrectly (
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-plummer authored Feb 21, 2023
1 parent 1e8b220 commit 2fcc507
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _Released 03/1/2023 (PENDING)_
- Added missing TypeScript type definitions for the [`cy.reload()`](https://docs.cypress.io/api/commands/reload) command. Addressed in [#25779](https://github.com/cypress-io/cypress/pull/25779).
- Ensure Angular components are mounted inside the correct element. Fixes [#24385](https://github.com/cypress-io/cypress/issues/24385)
- Fix a bug where files outside the project root in a monorepo are not correctly served when using Vite. Addressed in [#25801](https://github.com/cypress-io/cypress/pull/25801)
- Fixed an issue where using [`cy.intercept`](https://docs.cypress.io/api/commands/intercept)'s `req.continue()` with a non-function parameter would not provide an appropriate error message. Fixed in [#25884](https://github.com/cypress-io/cypress/pull/25884).

**Misc:**

Expand Down
24 changes: 24 additions & 0 deletions packages/driver/cypress/e2e/commands/net_stubbing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,30 @@ describe('network stubbing', { retries: 15 }, function () {
}).visit('/dump-method')
})

it('fails test if both req.reply and req.continue are called in req handler', function (done) {
testFail((err) => {
expect(err.message).to.contain('`req.reply()` and/or `req.continue()` were called to signal request completion multiple times, but a request can only be completed once')
done()
})

cy.intercept('/dump-method', function (req) {
req.reply()

req.continue()
}).visit('/dump-method')
})

it('fails test if req.continue is called with a non-function parameter', function (done) {
testFail((err) => {
expect(err.message).to.contain('\`req.continue\` requires the parameter to be a function')
done()
})

cy.intercept('/dump-method', function (req) {
req.continue({} as any)
}).visit('/dump-method')
})

it('fails test if req.reply is called after req handler finishes', function (done) {
testFail((err) => {
expect(err.message).to.contain('> `req.reply()` was called after the request handler finished executing')
Expand Down
1 change: 1 addition & 0 deletions packages/driver/src/cypress/error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@ export default {
You passed: ${format(eventName)}`, 10)
},
req_continue_fn_only: '\`req.continue\` requires the parameter to be a function',
event_needs_handler: `\`req.on()\` requires the second parameter to be a function.`,
defineproperty_is_not_allowed: `\`defineProperty()\` is not allowed.`,
setprototypeof_is_not_allowed: `\`setPrototypeOf()\` is not allowed.`,
Expand Down

4 comments on commit 2fcc507

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2fcc507 Feb 21, 2023

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-arm64/develop-2fcc5076d371806f6e7c3276d82d4213d4a4fedd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2fcc507 Feb 21, 2023

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-x64/develop-2fcc5076d371806f6e7c3276d82d4213d4a4fedd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2fcc507 Feb 21, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/darwin-x64/develop-2fcc5076d371806f6e7c3276d82d4213d4a4fedd/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2fcc507 Feb 21, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/win32-x64/develop-2fcc5076d371806f6e7c3276d82d4213d4a4fedd/cypress.tgz

Please sign in to comment.