I am building a React Js application using Typescript. I am writing integration tests for my application using Cypress. I am also using Typescript for writing Cypress tests. I am now trying to set the content of the tiny MCE editor in the Cypress test. I am trying to use this library, https://github.com/ForeachOS/cypress-tinymce. But I cannot use that library with TypeScript as it is only for JavaScript. So I had a look at the underlying code that sets the value of the editor. It is as follow.
Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => {
cy.window().then((win) => {
const editor = win.tinymce.editors[tinyMceId];
editor.setContent(content);
});
});
So I tried to create the TypeScript version of that command in my support/index.js file as follow.
Cypress.Commands.add('setTinyMceContent', (tinyMceId: string, content: any) => {
cy.window().then((win) => {
const editor = win.tinymce.editors[tinyMceId];
editor.setContent(content);
})
})
But it is complaining as follow.
Property 'tinymce' does not exist on type 'AUTWindow'.
How can I fix it?