Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
skip detox tests on api failure

I was trying to skip the tests based on API failure for detox tests in which I am using jest as test runner

const itif = (condition) => condition ? it : it.skip;

const itif = (condition) => condition ? it : it.skip;

describe('Example', () => {
    let condition1;
    let condition2;

  beforeEach(async () => {
    condition1 = await getResponseverifyArticles() ? true :false
    condition2 = await getNumberOfFollowers() ? true :false
    await device.launchApp();
  });
    
    
   console.log(condtion1) // --> giving undefined
   
   //so first test always skips 

  itif(condition1)('should verify articles1' ,async() => {
     await expect(element(by.text('Articles:'))).toBeVisible()
     await getResponseverifyArticles()
     await  expect(element(by.text('Articles:'))).toBeVisible()
  });

  //same as aboue
  
  itif(condition2)('should see Articles screen2', async () => {
    await expect(element(by.text('Articles:'))).toBeVisible()
    await getNumberOfFollowers()
  });


});

async function getArticles() {
    let articles;
    await axios
    .get('https://raw.githubusercontent.com/adhithiravi/React-Hooks-Examples/master/testAPI.json')
    .then(response => {
      if (response.status === 200 || response.status === 201) {
        articles = response.data.articles
      } 
    
    })
    .catch(error => {
      console.error("error Message :",error.response.data)
    
    });

    return articles

}

 const getResponseverifyArticles = async()=>{
  const res = await getArticles();
    for (let item of res) {
      await expect(element(by.text(item.title))).toBeVisible()
    }  
}






async function getNumberOfFollowers() {
  let nOfFollowers 
  await axios
  .get('https://api.github.com/users/janbodnar')
  .then(response => {
    if (response.status === 200 || response.status === 201) {
      nOfFollowers = response.data.followers;
    } 
  
  })
  .catch(error => {
        console.warn("Requested URL :",error.response)
  });

  return nOfFollowers
}
 
getNumberOfFollowers()

In this way, I was trying to skip the tests...but not able to access the condions from beforeAll block. Is there any way to access those conditions dynamically.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!