Skip to content

Commit e1455d8

Browse files
committed
eventType -> constructor
1 parent 8d1b5b5 commit e1455d8

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

cli/types/cypress.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,7 @@ declare namespace Cypress {
29142914
*
29152915
* @default 'Event'
29162916
*/
2917-
eventType: string
2917+
constructor: string
29182918
}
29192919

29202920
/** Options to change the default behavior of .writeFile */

packages/driver/cypress/integration/commands/actions/trigger_spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('src/cy/commands/actions/trigger', () => {
225225
})
226226

227227
cy.get('input:first').trigger('mousedown', {
228-
eventType: 'MouseEvent',
228+
constructor: 'MouseEvent',
229229
button: 0,
230230
shiftKey: false,
231231
ctrlKey: false,
@@ -778,7 +778,7 @@ describe('src/cy/commands/actions/trigger', () => {
778778
})
779779

780780
cy.get('input:first').trigger('keydown', {
781-
eventType: 'KeyboardEvent',
781+
constructor: 'KeyboardEvent',
782782
keyCode: 65,
783783
which: 65,
784784
shiftKey: false,
@@ -790,7 +790,7 @@ describe('src/cy/commands/actions/trigger', () => {
790790
cy.visit('fixtures/issue-5650.html')
791791

792792
cy.get('#test-input').trigger('keydown', {
793-
eventType: 'KeyboardEvent',
793+
constructor: 'KeyboardEvent',
794794
keyCode: 65,
795795
which: 65,
796796
shiftKey: false,
@@ -813,7 +813,7 @@ describe('src/cy/commands/actions/trigger', () => {
813813
})
814814

815815
cy.get('input:first').trigger('mousedown', {
816-
eventType: 'MouseEvent',
816+
constructor: 'MouseEvent',
817817
button: 0,
818818
shiftKey: false,
819819
ctrlKey: false,
@@ -823,7 +823,7 @@ describe('src/cy/commands/actions/trigger', () => {
823823
it('should trigger MouseEvent with .trigger inside html script event listener', () => {
824824
cy.visit('fixtures/issue-5650.html')
825825
cy.get('#test-input').trigger('mousedown', {
826-
eventType: 'MouseEvent',
826+
constructor: 'MouseEvent',
827827
button: 0,
828828
shiftKey: false,
829829
ctrlKey: false,
@@ -958,13 +958,13 @@ describe('src/cy/commands/actions/trigger', () => {
958958
it('throws when provided invalid event type', function (done) {
959959
cy.on('fail', (err) => {
960960
expect(this.logs.length).to.eq(2)
961-
expect(err.message).to.eq('Timed out retrying: `cy.trigger()` `eventType` option must be a valid event (e.g. \'MouseEvent\', \'KeyboardEvent\'). You passed: `FooEvent`')
961+
expect(err.message).to.eq('Timed out retrying: `cy.trigger()` `constructor` option must be a valid event (e.g. \'MouseEvent\', \'KeyboardEvent\'). You passed: `FooEvent`')
962962

963963
done()
964964
})
965965

966966
cy.get('button:first').trigger('mouseover', {
967-
eventType: 'FooEvent',
967+
constructor: 'FooEvent',
968968
})
969969
})
970970

packages/driver/src/cy/commands/actions/trigger.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ const $errUtils = require('../../../cypress/error_utils')
66
const $actionability = require('../../actionability')
77

88
const dispatch = (target, appWindow, eventName, options) => {
9-
const eventType = options.eventType ?? 'Event'
10-
const ctor = appWindow[eventType]
9+
const constructor = options.constructor ?? 'Event'
10+
const ctor = appWindow[constructor]
1111

1212
if (typeof ctor !== 'function') {
1313
$errUtils.throwErrByPath('trigger.invalid_event_type', {
14-
args: { eventType },
14+
args: { constructor },
1515
})
1616
}
1717

18-
// eventType property should not be added to event instance.
19-
delete options.eventType
18+
// constructor property should not be added to event instance.
19+
delete options.constructor
2020

2121
// https://github.com/cypress-io/cypress/issues/3686
2222
// UIEvent and its derived events like MouseEvent, KeyboardEvent

packages/driver/src/cypress/error_messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ module.exports = {
15101510
docsUrl: 'https://on.cypress.io/trigger',
15111511
},
15121512
invalid_event_type: {
1513-
message: `${cmd('trigger')} \`eventType\` option must be a valid event (e.g. 'MouseEvent', 'KeyboardEvent'). You passed: \`{{eventType}}\``,
1513+
message: `${cmd('trigger')} \`constructor\` option must be a valid event (e.g. 'MouseEvent', 'KeyboardEvent'). You passed: \`{{constructor}}\``,
15141514
docsUrl: 'https://on.cypress.io/trigger',
15151515
},
15161516
},

0 commit comments

Comments
 (0)