Creating your Own Skip Functions

We can create the helper function.

skip_if_no_api() <- function() {
  if (api_unavailable()) {
    skip("API not available")
  }
}

And later used each time needed.

test_that("foo api returns bar when given baz", {
  skip_if_no_api()
  ...
})

test_that("foo api returns an errors when given qux", {
  skip_if_no_api()
  ...
})