vitest-react-native
vitest-react-native copied to clipboard
Does not work on Windows due to path and caching issues
I'm trying to use this to migrate the couple RN-related test files for React-Redux ( https://github.com/reduxjs/react-redux ) as part of switching from Jest to Vitest.
I've found a couple places where this doesn't work right on Windows:
- A hardcoded check for Unix-style paths:
https://github.com/sheremet-va/vitest-react-native/blob/e4426a2ea45c71cc29306a8b9de5f35a3d93d44a/packages/vitest-react-native/setup.js#L106
I replaced this with:
matcher: (path) => {
const reReactNative = /node_modules(\\|\/)react-native(\\|\/)/
const matches = reReactNative.test(path)
// renderer doesn't have jsx inside and it's too big to process
&& !path.includes('Renderer/implementations')
return matches;
}
- The cache dir creation doesn't correctly create the trailing
/node_modules/folder. Fixed with:
const writeToCache = (cachePath, code) => {
const finalCacheDir = path.dirname(cachePath);
if (!fs.existsSync(finalCacheDir)) {
fs.mkdirSync(finalCacheDir, { recursive: true })
}
fs.writeFileSync(cachePath, code)
}
However, I'm then running into this error and don't have any idea what to do with this one:
· |React Native| test/react-native/batch-integration.tsx (8)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Invariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules
❯ invariant node_modules/invariant/invariant.js:40:15
❯ Object.<anonymous> node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:117:3
❯ Module._compile node:internal/modules/cjs/loader:1254:14
❯ Module._compile node_modules/vitest-react-native/node_modules/pirates/lib/index.js:136:24
❯ Module._extensions..js node:internal/modules/cjs/loader:1308:10
❯ Object.newLoader [as .js] node_modules/vitest-react-native/node_modules/pirates/lib/index.js:141:7
❯ Module.load node:internal/modules/cjs/loader:1117:32
❯ Function.Module._load node:internal/modules/cjs/loader:958:12
❯ Module.require node:internal/modules/cjs/loader:1141:19
❯ require node:internal/modules/cjs/helpers:110:18
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
"framesToPop": 1,
}
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Test Files (1)
Tests (8)
Errors 1 error
Any suggestions?
I cannot help you without actual reproduction. The path errors are fixed in 0.1.2.