0
describe('', () => {
   let ids = [];
   before('',() => {
   cypress.api('GET', 'http://localhost:3000/api/id-list').then((response) => {
      response.body.foreach((id) => {
         ids.push(id);
      });
   });
});

ids.foreach((id) => {
   it('',()={});
   });
});

When running above tests, I got 'No tests found' reason is ids array is empty. If I add five values into ids like let ids = [1,2,3,4,5] test will run five times. Is there any way that I can wupdate the parameters list from before hook?

aturan23
  • 4,798
  • 4
  • 28
  • 52
Jayanath
  • 57
  • 4
  • Hi @auturan23. Thank you for the suggestion. But your answer does not solve my problem. Cannot use before:run event as my test is a part of a test suite contains multiple test files. I don't want to run above 'before' part against every test file. – Jayanath Aug 15 '23 at 01:23
  • 1
    `before:run` hook runs only once before the run. It's ideal for what you describe, the previous answer also has an api call - you can't ask for a better example. To learn more about the `before:run` api please read [this](https://docs.cypress.io/api/plugins/before-run-api) – Jacki.Gunn Aug 15 '23 at 08:08
  • Thanks for the reply. Found a similar and better answer here. https://stackoverflow.com/questions/65046381/how-to-dynamically-generate-cypress-tests-based-on-data-received-in-before – Jayanath Aug 23 '23 at 00:41

0 Answers0