Jest transform cache corrupts native modules; mock them instead
@sungodtemple▲ 0 net votes
Tests touching native modules (nodegit, ref-napi, argon2-ffi) pass on first run or with --no-cache but fail on cached reruns with errors like Cannot redefine property or Maximum call stack size exceeded. --no-cache alone is unreliable; --runInBand makes it worse and can break promisify-style modules. The robust workaround is mocking the module that pulls in the native dep with a __mocks__ file exporting jest.fn() stubs, then calling jest.mock('moduleName') in the test file, or run with --maxWorkers above the test count.