mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
The fork existed only to strip the package's `exports` map so metro would bundle the TS source; upstream now ships a build that react-native consumes directly (README documents the polyfills, all of which the app already installs), so the fork has no reason to exist. Fallout of the upgrade: - `subscribeMany` now takes a single filter rather than an array. - `SimplePool` drops a relay from its map when it gives up on it, so an empty map - not a `false` status - is what "everything is down" looks like now. Opt into `enableReconnect` so the pool restores dropped connections and refires their subscriptions with an advanced `since`. - `message-port-polyfill` was there for the old nostr-tools; nothing in the tree references MessagePort any more. - The published build is plain CJS/ESM, so jest can load the real library and the mock that stood in for it is gone. Nested @noble copies need babel, hence the transformIgnorePatterns tweak. Covered by a NIP-06 derivation test against the standard vector, so the identity the wallet derives from a seed phrase is provably unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
45 lines
2.9 KiB
JavaScript
45 lines
2.9 KiB
JavaScript
module.exports = {
|
|
preset: 'react-native',
|
|
// Only treat *.test/*.spec files as tests. The default preset glob also
|
|
// matches every .js file under __tests__, which would pull in the i18n
|
|
// scripts (missingTranslations.js etc.) that are run via `yarn test:i18n`.
|
|
testMatch: ['**/*.(test|spec).[jt]s?(x)'],
|
|
// The `(.*/)?` makes the allowlist apply at any depth: nostr-tools carries its
|
|
// own ESM-only @noble copies in a nested node_modules, and those need babel too.
|
|
transformIgnorePatterns: [
|
|
'node_modules/(?!(.*/)?((jest-)?react-native|@react-native|@react-native-community|@cashu|@noble|@scure|react-native-flash-message)/)',
|
|
],
|
|
// Several native or source-shipped packages are unusable under jest, and the
|
|
// MODEL layer reaches all of them at import time (Mint -> services barrel ->
|
|
// mmkvStorage / keyChain / db). That is what made MST stores impossible to
|
|
// instantiate in a test at all; these mappings are what make store tests possible.
|
|
moduleNameMapper: {
|
|
// Same shape as the @scure/bip39 mapping below: the package's exports map
|
|
// names only the suffixed path, so app code imports it that way. This accepts
|
|
// both spellings, for transitive dependencies still using the bare one.
|
|
'^@noble/hashes/utils(?:\\.js)?$': '@noble/hashes/utils.js',
|
|
// The package's exports map lists ONLY the explicit `.js` subpath, so app code
|
|
// imports it that way (moduleResolution is "bundler", which honours exports).
|
|
// This accepts both spellings, since a transitive dependency may still use the
|
|
// extensionless one, which no resolver can infer from that map.
|
|
'^@scure/bip39/wordlists/([^/.]+)(?:\\.js)?$': '@scure/bip39/wordlists/$1.js',
|
|
// quick-crypto's native module is unavailable under jest; route to a
|
|
// Node `crypto` shim so deps that import it at load time (e.g. bip32) work.
|
|
'^react-native-quick-crypto$': '<rootDir>/__mocks__/react-native-quick-crypto.js',
|
|
// MMKV and op-sqlite are native. MMKV is Map-backed and behaves; op-sqlite is
|
|
// only an import-time shim and throws if a statement is actually executed —
|
|
// use node:sqlite with the production SQL for real DB semantics (see the db
|
|
// suites).
|
|
'^react-native-mmkv$': '<rootDir>/__mocks__/react-native-mmkv.js',
|
|
'^@op-engineering/op-sqlite$': '<rootDir>/__mocks__/op-sqlite.js',
|
|
// Sentry ships untransformed ESM, so anything importing logService fails to
|
|
// parse. Mocking Sentry rather than logService lets the REAL logger load, so
|
|
// tests can cover code that logs instead of stubbing the logger away.
|
|
'^@sentry/react-native$': '<rootDir>/__mocks__/sentry-react-native.js',
|
|
// react-native-localize is a native TurboModule, and src/i18n calls getLocales()
|
|
// at module scope — so without this, importing `translate` anywhere makes the
|
|
// module unloadable under jest.
|
|
'^react-native-localize$': '<rootDir>/__mocks__/react-native-localize.js',
|
|
},
|
|
}
|