async function checkBuildStatus(buildId, numRetries, resolve) {
  const response = await percyClient.getBuild(buildId);
  const {body: {data: {attributes}}}  = response;
  const {state} = attributes;
  if (state == 'processing' || state == 'pending') {
      retry(buildId, numRetries, resolve);
  } else if (state == 'finished'){
    // Unreviewed diffs are the diffs which have not been approved in the percy UI
    const totalUnreviewed = attributes['total-snapshots-unreviewed'];
      if (totalUnreviewed) {
        const url = attributes['web-url'];
        handleError('percy', `unreviewed diffs found: ${totalUnreviewed}. Check ${url}`);
      } else {
        logger.log('Hooray! The build is successful with no unreviewed diffs. \\o/');
      }
      resolve();
  } else if (state == 'failed') {
    handleError('percy', `build failed: ${attributes['failure-reason']}`);
    resolve();
  }
}
/**
 * Retrieve the build information from the Percy server, send another request to the server
 * if the build state is processing or pending. Once the build is finished, check for diffs and
 * display errors if there are diffs.
 * @param {string} buildId Percy Build ID.
 * @param {number} numRetries The number of get build requests to the server.
 * @param {Function} resolve Promise resolve function.
 */
Retrieve the build information from the Percy server, send another request to the server
if the build state is processing or pending. Once the build is finished, check for diffs and
display errors if there are diffs.
@param {string} buildId Percy Build ID.
@param {number} numRetries The number of get build requests to the server.
@param {Function} resolve Promise resolve function.
Retrieve the build information from the Percy server send another request to the server if the build state is processing or pending . Once the build is finished check for diffs and display errors if there are diffs . @param { string } buildId Percy Build ID . @param { number } numRetries The number of get build requests to the server . @param { Function } resolve Promise resolve function .
async function checkBuildStatus(buildId, numRetries, resolve) {
  const response = await percyClient.getBuild(buildId);
  const {body: {data: {attributes}}}  = response;
  const {state} = attributes;
  if (state == 'processing' || state == 'pending') {
      retry(buildId, numRetries, resolve);
  } else if (state == 'finished'){
    const totalUnreviewed = attributes['total-snapshots-unreviewed'];
      if (totalUnreviewed) {
        const url = attributes['web-url'];
        handleError('percy', `unreviewed diffs found: ${totalUnreviewed}. Check ${url}`);
      } else {
        logger.log('Hooray! The build is successful with no unreviewed diffs. \\o/');
      }
      resolve();
  } else if (state == 'failed') {
    handleError('percy', `build failed: ${attributes['failure-reason']}`);
    resolve();
  }
}
async function checkBuildStatus ( buildId , numRetries , resolve ) { const response = await percyClient . getBuild ( buildId ) ; const { body : { data : { attributes } } } = response ; const { state } = attributes ; if ( state == 'processing' || state == 'pending' ) { retry ( buildId , numRetries , resolve ) ; } else if ( state == 'finished' ) { const totalUnreviewed = attributes [ 'total-snapshots-unreviewed' ] ; if ( totalUnreviewed ) { const url = attributes [ 'web-url' ] ; handleError ( 'percy' , ` ${ totalUnreviewed } ${ url } ` ) ; } else { logger . log ( 'Hooray! The build is successful with no unreviewed diffs. \\o/' ) ; } resolve ( ) ; } else if ( state == 'failed' ) { handleError ( 'percy' , ` ${ attributes [ 'failure-reason' ] } ` ) ; resolve ( ) ; } }
Retrieve the build information from the Percy server, send another request to the server
 if the build state is processing or pending.
Retrieve the build information from the Percy server send another request to the server if the build state is processing or pending .
// Unreviewed diffs are the diffs which have not been approved in the percy UI