Skip to content

Releases: richardguerre/use-relay-mock-environment

v1.6.0

07 Jun 18:02
Compare
Choose a tag to compare
  • fix RelayEnvironmentProvider not used 236930e
  • export react-relay@11.0.2 63a81d7

v1.5.3...v1.6.0

v1.5.3

02 Nov 08:26
Compare
Choose a tag to compare

v1.5.2...v1.5.3

v1.5.2

02 Nov 08:19
Compare
Choose a tag to compare
  • ignore There are no pending operations in the list errors 5d13989

v1.5.1...v1.5.2

v1.5.1

27 Oct 02:57
Compare
Choose a tag to compare

v1.5.0...v1.5.1

v1.5.0

23 Oct 13:44
Compare
Choose a tag to compare
  • Generate inline fragments with different __typenames 9b89ce4
  • add more debugging + add searchTypeByPath + add searchTypeByName a4324bf
  • update docs 5f049af

v1.4.0...v1.5.0

v1.4.0

03 Oct 09:25
Compare
Choose a tag to compare
  • update README b0c9caf
  • add monitorContext option to get console logs of String context resolver 85f0423
  • add mockNull and mockUndefined to mock null/undefined resolution 4e28218

v1.3.0...v1.4.0

v1.3.0

30 Jul 20:16
2b2f109
Compare
Choose a tag to compare
  • Adds seed option (#1)
  • Adds forceInstantInitialLoading global option (#2)

Notable updates:
Useful in visual test tools like Stroybook's Chromatic (https://chromatic.com/) or Percy (https://percy.io) where you need consistent data to render the same UI and prevent false positives.

You can set it when invoking createUseRelayMockEnvironment:

const useRelayMockEnvironment = createUseRelayMockEnvironment({
  // ... your other options
  seed: 'my seed' // can be a string or number
});

And/or set it when using the hook:

const environment = useRelayMockEnvironment({
  // ... your other options
  seed: 123 // can be a string or number
});

Note: When it is set in both createUseRelayMockEnvironment and useRelayMockEnvironment, the seed in useRelayMockEnvironment takes priority.


When using a visual testing tool like Chromatic, you can enforce having consistent fake data by providing the seed, instantInitialLoading and/or forceInstantInitialLoading options. We recommend passing these options at the global level, when invoking createRelayMockEnvironmentHook():

// useRelayMockEnvironment.(js | jsx | ts | tsx)
import { createRelayMockEnvironmentHook } from 'use-relay-mock-environment';
import isChromatic from 'chromatic/isChromatic';

const useRelayMockEnvironment = createRelayMockEnvironmentHook({
  ...(isChromatic()
    ? {
        seed: 123, // can be anything you want (string or number)
        forceInstantInitialLoading: true,
      }
    : {}),
  // Add any other global options here (optional)
});

export default useRelayMockEnvironment;