Context
react-native-css has three test domains in src/__tests__/:
babel/— Babel plugin tests usingbabel-plugin-testercompiler/— CSS compilation tests verifying JSON outputnative/— Runtime tests for style application
Conventions by domain
Babel tests (src/__tests__/babel/)
Use babel-plugin-tester:
import { pluginTester } from "babel-plugin-tester";
pluginTester({
plugin,
tests: {
"test name": {
code: `import { View } from 'react-native';`,
output: `import { View } from 'react-native-css/components';`,
},
},
});
Compiler tests (src/__tests__/compiler/)
Verify CSS → JSON compilation output structure.
Native tests (src/__tests__/native/)
Test runtime style application on native platform.
Steps
Identify the feature: What needs testing? Use
$ARGUMENTSas the starting point.Determine the domain: Is this a babel transform, compiler output, or runtime behavior?
Find existing tests: Search the appropriate
src/__tests__/subdirectory for similar tests.Write the test: Follow the conventions of the domain.
Run the test: Execute
yarn test. Note: ignoreExperimentalWarning: VM Moduleswarnings — they're expected.