Testing
Testing
Our SDKs and Clients have library and language-specific testing advice. We recommend you checkout the docs for the SDK or client you're using.
To keep your tests speedy and consistent, we recommend avoiding connections to our server and to instead prefer relying on local data for test setup.
Specifying a PrefabEnv of 'test' and putting data in .prefab.test.config.yaml
is covered in Default Files.
Server-side SDKs
Specify LOCAL_ONLY
and use your config.yaml file.
- Ruby
- Java
- Elixir
options = Prefab::Options.new(data_sources: LOCAL_ONLY)
client = Prefab::Client.initialize(options)
Options options = new Options()
.setPrefabDatasource(Options.Datasources.LOCAL_ONLY)
options = Prefab.Options.new(prefab_datasources: :local_only)
client = Prefab.Client.new(options)
Client-side Libraries
Rather than talking to the server, use setConfig
or use a Provider
manually with your test setup.
- JavaScript
- React
Don't call prefab.init
. Instead, use setConfig
to set up your scenario.
prefab.setConfig({
turbo: true,
defaultMediaCount: 3,
});
Don't use the PrefabProvider
. Instead, use the PrefabTestProvider
and pass in a config object.
<PrefabTestProvider config={config}>
<MyComponent />
</PrefabTestProvider>,