How to use the relay-test-utils.createMockEnvironment function in relay-test-utils

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 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 3 months ago

Package Health Score

93 / 100
Full package analysis