How to use the unexpected.fail function in unexpected

To help you get started, we’ve selected a few unexpected examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FreeFeed / freefeed-server / test / functional / functional_test_helper.js View on Github external
export async function fetchTimeline(path, viewerContext = null) {
  const headers = {};

  if (viewerContext) {
    headers['X-Authentication-Token'] = viewerContext.authToken;
  }

  const response = await fetch(
    await apiUrl(`/v2/timelines/${path}`),
    { agent, headers }
  );
  const feed = await response.json();

  // console.log(feed);
  if (response.status !== 200) {
    expect.fail('HTTP error (code {0}): {1}', response.status, feed.err);
  }

  expect(feed, 'to exhaustively satisfy', schema.timelineResponse);
  return feed;
}
github FreeFeed / freefeed-server / test / functional / timelines-everything.js View on Github external
async function fetchEverything(viewerContext = null) {
  const headers = {};

  if (viewerContext) {
    headers['X-Authentication-Token'] = viewerContext.authToken;
  }

  const response = await performRequest(`/v2/everything`, {  headers });
  const feed = await response.json();

  // console.log(feed);
  if (response.status !== 200) {
    expect.fail('HTTP error (code {0}): {1}', response.status, feed.err);
  }

  expect(feed, 'to exhaustively satisfy', schema.everythingResponse);
  return feed;
}
github FreeFeed / freefeed-server / test / functional / posts.js View on Github external
const updatePost = async (postObj, userContext, parameters) => {
        const res = await funcTestHelper.updatePostAsync({ ...userContext, post: postObj }, parameters);
        const body = await res.json();

        if (res.status != 200) {
          expect.fail(`Error updating post (${res.status}): ${body.err}`);
        }

        return body;
      };
github FreeFeed / freefeed-server / test / functional / timelines-rss.js View on Github external
async function fetchMetatags(username) {
  const response = await performRequest(`/v2/timelines-metatags/${username}`);

  if (response.status !== 200) {
    const { err } = await response.json();
    expect.fail('HTTP error (code {0}): {1}', response.status, err);
  }

  return await response.text();
}
github FreeFeed / freefeed-server / test / functional / postsV2.js View on Github external
const postOpenGraphFetcher = (app) => async (postId) => {
  const res = await fetch(`${app.context.config.host}/v2/posts-opengraph/${postId}`);

  if (res.status !== 200) {
    expect.fail('HTTP error (code {0})', res.status);
  }

  return await res.text();
};
github FreeFeed / freefeed-server / test / functional / functional_test_helper.js View on Github external
if (viewerContext) {
    headers['X-Authentication-Token'] = viewerContext.authToken;
  }

  const response = await fetch(
    await apiUrl(`/${params.apiVersion}/posts/${postId}?maxComments=${params.allComments ? 'all' : ''}&maxLikes=${params.allLikes ? 'all' : ''}`),
    { agent, headers }
  );
  const post = await response.json();

  if (response.status !== 200) {
    if (params.returnError) {
      return response;
    }

    expect.fail('HTTP error (code {0}): {1}', response.status, post.err);
  }

  if (params.apiVersion === 'v2') {
    expect(post, 'to exhaustively satisfy', schema.postResponse);
  }

  return post;
}

unexpected

Extensible BDD assertion toolkit

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis