avajs/ava

Feature Request: A way to mark a test 'skipped' after it starts

Open

#2,010 opened on Jan 9, 2019

View on GitHub
 (12 comments) (2 reactions) (0 assignees)JavaScript (20,600 stars) (1,408 forks)batch import
enhancementhelp wantedscope:assertions

Description

Description

I'm using ava to control selenium-webdriver for tests run in Firefox and Chrome. It cannot be known synchronously if the browser can be run. An example flow could be:

test('somepage.html', async t => {
  try {
    await loadPage('somepage.html');
  } catch (error) {
    t.skip();
    return;
  }
  // testing against the page here
});

In this example loadPage() will reject if the browser cannot be started, otherwise it will resolve. The goal is that the test will report skipped if the browser cannot be run.

It would probably be good if t.skip() threw an exception if any assertions have already run for that test.

Environment

Node.js v10.14.2
linux 4.19.8-200.fc28.x86_64
ava 1.0.1
npm 6.4.1

Contributor guide