How to use relay-test-utils - 9 common examples

To help you get started, we’ve selected a few relay-test-utils 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 renanmav / relayable / packages / web / src / relay / createQueryRendererModern.tsx View on Github external
import React from 'react'
import { GraphQLTaggedNode, Variables } from 'relay-runtime'
import { QueryRenderer } from 'react-relay'
import hoistStatics from 'hoist-non-react-statics'
import { createMockEnvironment } from 'relay-test-utils'

import { Environment } from '.'

interface Config {
  query?: GraphQLTaggedNode
  queriesParams?: (props: Object) => Object
  variables?: Variables
  hideSplash?: boolean
}

export const env = createMockEnvironment()

export default function createQueryRenderer(
  FragmentComponent: React.ComponentType,
  Component: React.ComponentType,
  config: Config,
  LoadingComponent?: React.ComponentType
) {
  const { query, queriesParams } = config

  function QueryRendererWrapper(props: Object) {
    const variables = (queriesParams ? queriesParams(props) : config.variables) as Variables

    return (
github entria / entria-fullstack / packages / web / src / __tests__ / UserList.spec.tsx View on Github external
Environment.mock.resolveMostRecentOperation((operation) =>
    MockPayloadGenerator.generate(operation),
    );
github renanmav / relayable / packages / web / src / modules / Navbar / __tests__ / Navbar.spec.tsx View on Github external
  env.mock.resolveMostRecentOperation(operation => MockPayloadGenerator.generate(operation))
github artsy / emission / src / lib / Scenes / Search / __tests__ / AutosuggestResults-tests.tsx View on Github external
    env.mock.resolveMostRecentOperation(op => MockPayloadGenerator.generate(op))
github artsy / emission / src / lib / Scenes / Artwork / __tests__ / Artwork-tests.tsx View on Github external
environment.mock.resolveMostRecentOperation(operation => {
      return MockPayloadGenerator.generate(operation)
    })
    expect(renderer.toJSON()).toMatchSnapshot()
github renanmav / relayable / packages / web / src / modules / Home / AskHeadline / __tests__ / AskHeadline.spec.tsx View on Github external
  env.mock.resolveMostRecentOperation(operation => MockPayloadGenerator.generate(operation))
github artsy / emission / src / lib / Components / Bidding / Screens / __tests__ / ConfirmBid-tests.tsx View on Github external
jest.mock("lib/relay/createEnvironment", () => ({
  defaultEnvironment: require("relay-test-utils").createMockEnvironment(),
}))
github artsy / emission / src / lib / Scenes / Search / __tests__ / AutosuggestResults-tests.tsx View on Github external
jest.mock("lib/relay/createEnvironment", () => ({
  defaultEnvironment: require("relay-test-utils").createMockEnvironment(),
}))
github artsy / emission / src / lib / Scenes / Artwork / __tests__ / Artwork-tests.tsx View on Github external
beforeEach(() => {
    environment = createMockEnvironment()
    ;(useTracking as jest.Mock).mockImplementation(() => {
      return {
        trackEvent,
      }
    })
  })

relay-test-utils

Utilities for testing Relay applications.

MIT
Latest version published 1 month ago

Package Health Score

88 / 100
Full package analysis