Ability to dynamically create tests while inside of a test - cannot create tests while tests are running
See original GitHub issueI am loading these based on some data, but to get it I need to run cy.task
to grab that data. For now let’s assume it’s a MySQL query via a plugin. I cannot use cy.task
outside of a test, so I am trying to add tests from within a test.
Another use case is that I am running a test, but I see a button. I have another set of tests that only run based on the existence of that button. I still want them in another separate context, so a separate dropdown.
Also, I cannot use it
inside of a cy.task
callback e.g. inside of myFunction
like with cy.task('readCSV', 'test.csv').then(myFunction);
Current behavior:
Parent task results waits forever. Perhaps related (https://github.com/webdriverio/webdriverio/issues/4963)
Desired behavior:
I would like to see “Another Test” in a separate row as per the code below. FYI: Doing this will work in puppeteer correctly.
Test code to reproduce
context('Set up', () => {
it('add tests', () => {
context('Another test', () => {
it('this title', () => {
expect(true).to.equal(true)
})
})
});
})
Versions
Debian 10, Cypress 4.8.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top GitHub Comments
Mocha has a command line option called “–delay”. This would be great to implement in cypress for those of us who have async operations they need to perform which inform the list of actual tests.
From their docs:
DELAYED ROOT SUITE
https://mochajs.org/#asynchronous-code If you need to perform asynchronous operations before any of your suites are run, you may delay the root suite. Run
mocha
with the--delay
flag. This will attach a special callback function,run()
, to the global context:I can and I do, but that isn’t quite what I am looking for.
The issue is that I want the flexibility to add these tests at runtime. For example, I would like a test to
Depending on what is on a certain page, I may need to run additional tests, since the structure could be entirely arbitrary or user defined. Even structures such as content types and their fields are not known to me ahead of time.
The idea is achieve a write-once set of tests, and transport them for use across multiple site installations with a wide variety of scenarios as to their configuration.
These tests are entirely decoupled from the site installation and need to be run remotely. Multiple people are changing the structures all at the same time, so when these run, I need to be able to report back to them continuously.