-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Can't seem to get this to work with Cypress 12.16.0 and Typescript #77
Comments
is this a TS error or an actual runtime error? |
it feels like a typescript error. the require was converted to an import, however even if i use require it still fails, i am using browserify in setupNodeEvents too |
Maybe use "// @ts-ignore" above the line to stop TS from complaining
…On Wed, Jul 5, 2023 at 2:56 PM Bob Bhatti ***@***.***> wrote:
it feels like a typescript error. the require was converted to an import,
however even if i use require it still fails, i am using browserify in
setupNodeEvents too
—
Reply to this email directly, view it on GitHub
<#77 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ4BJQ2ZV7F7CQQFKWSIVLXOW2HLANCNFSM6AAAAAAZ6AUWYE>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Dr. Gleb Bahmutov, PhD
Schedule video chat / phone call / meeting with me via
https://calendly.com/bahmutov
***@***.*** @bahmutov ***@***.***>
https://glebbahmutov.com/ https://glebbahmutov.com/blog
https://github.com/bahmutov
|
ah cool thanks, will give it a go thank you |
@bahmutov I am having the same issue. If I try to use import cypressSplit from 'cypress-split'; I would need to create a custom type declaration file declare module 'cypress-split' {
export default function cypressSplit(
on: PluginEvents,
config: PluginConfigOptions
): Promise<PluginConfigOptions | void> | PluginConfigOptions | void;
} But when trying to boot up cypress, I get this error Your configFile threw an error from: /root/project/apps/XXX/cypress.config.ts
The error was thrown while executing your e2e.setupNodeEvents() function:
TypeError: (0 , cypress_split_1.default) is not a function at setupNodeEvents
(/root/project/apps/XXX/cypress.config.ts:12:19)
at /root/.cache/Cypress/12.11.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:122:14 The solution to this is to use // eslint-disable-next-line @typescript-eslint/no-var-requires
const cypressSplit = require('cypress-split'); I think the ultimate solution would be:
Then TS projects could automatically import these type declarations. |
Use: import * as cypressSplit from 'cypress-split'; |
@Baune8D I tried this and the linting error is:
The reason is that I have noImplicitAny set to |
@Elte156 Yeah you proberly need to implement your own typings. But it will fix the |
🎉 This issue has been resolved in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@bahmutov thanks for releasing 1.5.0. I was able to use import cypressSplit from 'cypress-split'; I still encountered the same error though: The error was thrown while executing your e2e.setupNodeEvents() function:
TypeError: (0 , cypress_split_1.default) is not a function
at setupNodeEvents (/XXX/cypress.config.ts:12:19)
at /root/.cache/Cypress/12.11.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:122:14 The solution was to add this to my tsconfig.json {
"compilerOptions": {
"esModuleInterop": true
}
} |
FYI You can import using |
@Baune8D If I do this I get this error in my IDE. This expression is not callable.
Type 'typeof import("/XXX/node_modules/cypress-split/src/types")' has no call signatures.ts(2349) So I either:
|
Yeah you are right,
|
FYI, on |
Yes it works if you use |
I created a PR that fixes this for both |
I am trying to run this with the following
Cypress 12.16.0
Typescript
Cypress-Cucumber-PreProcessor
Am receiving the following error
The error was thrown while executing your e2e.setupNodeEvents() function:
TypeError: (0 , cypress_split_1.cypressSplit) is not a function
What am I doing wrong?
The text was updated successfully, but these errors were encountered: