-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
plugins.js - async/await causes invalid import errors #7011
Comments
Also occurs if any of the imported/required files use async. Reproducable codehelper.js export async function sayWelcome() {} plugins.js const helper = require('./helper')
// import helper from './helper' does not make a difference
module.exports = (on, config) => {
on('task', {
'hello-world': () => () {
return helper.sayWelcome()
}
})
} According to #7006 my |
I have a related problem problem but for another usage of tslib and I don't have async functions here. I don't even have typescript in those tests codebase and I don't have any plugin files.
|
Possible same issue like #7005 @EtienneBruines can you try my workaround? plugins.ts function plugins(on: Cypress.PluginEvents, _config: Cypress.ConfigOptions): void {
on('before:browser:launch', () => {
console.log("hello");
});
}
module.exports = plugins; |
@CSchulz I thought about it (and really liked learning that IIRC function plugins(on: Cypress.PluginEvents, _config: Cypress.ConfigOptions): void {
on('before:browser:launch', () => {
console.log("hello");
});
}
module.exports = plugins; the above works, but this one does not: function plugins(on: Cypress.PluginEvents, _config: Cypress.ConfigOptions): void {
on('before:browser:launch', async () => {
console.log("hello");
});
}
module.exports = plugins; |
I'm having similar problems when setting "importHelpers" to true in the tsconfig.json file, although I'm not 100% sure this is the same issue, given that my plugins file is still a ".js". I can prepare a minimal reproduction if you think it'd be helpful in any way. |
@EtienneBruines could you paste your |
Can someone provide a reproducible example - I have placed async and import code in https://github.com/cypress-io/cypress-test-tiny/tree/async-problem-7011 and Cypress 4.5.0 skips loading
{
"compilerOptions": {
"module": "esnext",
"allowJs": true,
"importHelpers": true
}
} Trying #7166 and it works. |
Tested with the latest on I have narrowed it down to this minimal {
"compilerOptions": {
"module": "esnext",
"allowJs": true,
"importHelpers": true
}
} Removing
Having no Full {
"compilerOptions": {
"experimentalDecorators": true,
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "esnext",
"target": "ES2016",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"strict": true,
"importHelpers": true,
"lib": [
"dom",
"webworker",
"es2015.promise"
]
},
"include": [
"**/*.ts",
"**/*.vue"
],
"exclude": [
"node_modules"
],
"files": [
"ts-shim.d.ts"
]
} Note that I'm testing this for |
The code for this is done in cypress-io/cypress#7197, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
Using
async
within aplugins.ts
file results in a (non-informative) error.Desired behavior:
No errors, as well as being able to use
async
.Test code to reproduce
plugins.ts
and alternatively
plugins.js
Versions
Note that the
plugins.js
file mentioned, was valid code in Cypress 4.3.0.The text was updated successfully, but these errors were encountered: