-
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
Defining tasks out of cypress config file #25970
Comments
@palcarazm This can already be accomplished in Cypress. You would be responding for defining. One way to do this is: // cypress/support/tasks.js
const addTasks = (on) => {
on('task', {
task1(message) {
console.log('task1', message)
return null
},
task2(message) {
console.log('task2', message)
return null
},
})
}
module.exports = addTasks // cypress.config.js
const addTasks = require('./cypress/support/tasks')
module.exports = {
setupNodeEvents(on, config) {
addTasks(on)
},
} |
emilyrohrbough
removed
the
type: feature
New feature that does not currently exist
label
Apr 12, 2023
Even if task are defined in multiple files? I didn't find it in the doc. // cypress/support/tasksA.js
const addTasksA = (on) => {
on('task', {
task1(message) {
console.log('task1', message)
return null
},
task2(message) {
console.log('task2', message)
return null
},
})
}
module.exports = addTasksA // cypress/support/tasksB.js
const addTasksB = (on) => {
on('task', {
task3(message) {
console.log('task3', message)
return null
},
task4(message) {
console.log('task4', message)
return null
},
})
}
module.exports = addTasksB |
If you have tasks across files, I'd suggest something like: const addTaskA = {
task1(message) {
console.log('task1', message)
return null
},
task2(message) {
console.log('task2', message)
return null
},
} const addTaskB = {
task3(message) {
console.log('task3', message)
return null
},
task4(message) {
console.log('task4', message)
return null
},
}
```js
```js
// cypress.config.js
const addTasksA = require('./cypress/support/tasksA')
const addTasksB = require('./cypress/support/tasksB')
module.exports = {
setupNodeEvents(on, config) {
on('task', {
...addTasksA,
...addTasksB,
},
} |
You cannot define multiple |
Okay thanks 😊 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What would you like?
In cypress config file add a list of filepaths containing task definition.
Why is this needed?
When using cucumber preprocesor all steps that hace todo use no de platform are broken except if you use cy.task().
When the test projet grow a large number of tasks can be defined in a single file. This is quite dificult to maintain.
Spliting task definition in some files will solve the issue.
Other
No response
The text was updated successfully, but these errors were encountered: