Writing custom stubs

When SootSim doesn’t have a builtin stub for a package you use, you can provide your own.

Config-based stubs

Noop (empty module)

// sootsim.config.ts
import { defineConfig } from 'sootsim/config'
export default defineConfig({
modules: {
'react-native-analytics': 'noop',
},
})

File stub

// stubs/camera.ts
export async function takePicture() {
return { uri: 'https://placekitten.com/400/400', width: 400, height: 400 }
}
export async function requestPermission() {
return { status: 'granted' }
}
// sootsim.config.ts
import { defineConfig } from 'sootsim/config'
export default defineConfig({
modules: {
'react-native-camera': { file: './stubs/camera.ts' },
},
})

Inline stub

import { defineConfig } from 'sootsim/config'
export default defineConfig({
modules: {
'react-native-config': {
inline: {
API_URL: 'http://localhost:3000',
ENV: 'development',
},
},
},
})

Guidelines

  • Export the same named exports as the original package
  • Use real browser APIs where possible (camera → getUserMedia, clipboard → navigator.clipboard)
  • For UI components, return a View/Text wrapper that renders children
  • For hooks, return sensible defaults
  • Never stub pure JS packages — they work as-is