I recently made a little Javascript bookmarklet to hide/toggle tests in pull requests. I found it useful for getting an initial overview of the work done in the commits before a full code review. It works on Chrome but due to CSP doesn’t seem to work on Firefox.

javascript: (() => {

let hideTests = !window.testsHidden;

let testFilenameEndings = ['Tests.cs', 'Tests.csproj', '.spec.ts'];

let files = document.querySelectorAll('.file-header');

for (let file of files) {
  var filename = file.querySelector('.file-info > a.link-gray-dark').innerText;

  let isTest = false;

  for (let ending of testFilenameEndings) {
    if (filename.endsWith(ending)) {
      isTest = true;
    }
  }

  if (!isTest) {
    continue;
  }

  let fileToggleButton = file.querySelector('.file-actions > button[aria-label="Toggle diff text"]');

  if (hideTests) {
    if (fileToggleButton.getAttribute('aria-expanded') === 'true') {
      fileToggleButton.click();
    }
  }
  else {
    if (fileToggleButton.getAttribute('aria-expanded') === 'false') {
      fileToggleButton.click();
    }
  }
}

window.testsHidden = hideTests;

})();