2022-11-23 13:59:18 +00:00
|
|
|
module.exports = {
|
2023-06-19 13:39:12 +00:00
|
|
|
preset: 'react-native',
|
Introduce malli library (#17867)
This commit is the foundational step to start using malli
(https://github.com/metosin/malli) in this project.
Take in consideration we will only be able to realize malli's full power in
future iterations.
For those without context: the mobile team watched a presentation about malli
and went through a light RFC to put everyone on the same page, among other
discussions here and there in PRs.
To keep things relatively short:
1. Unit, integration and component tests will short-circuit (fail) when
inputs/outputs don't conform to their respective function schemas (CI should
fail too).
2. Failed schema checks will not block the app from initializing, nor throw an
exception that would trigger the LogBox. Exceptions are only thrown in the
scope of automated tests.
3. There's zero performance impact in production code because we only
instrument. Instrumentation is removed from the compiled code due to the
usage of "^boolean js.goog/DEBUG".
4. We shouldn't expect any meaningful slowdown during development.
**What are we instrumenting in this PR?**
Per our team's agreement, we're only instrumenting the bare minimum to showcase 2 examples.
- Instrument a utility function utils.money/format-amount using the macro
approach.
- Instrument a quo component quo.components.counter.step.view/view using the
functional approach.
Both approaches are useful, the functional approach is powerful and allow us to
instrument anonymous functions, like the ones we pass to subscriptions or event
handlers, or the higher-order function quo.theme/with-theme. The macro approach
is perfect for functions already defined with defn.
**I evaluated the schema or function in the REPL but nothing changes**
- If you evaluate the source function, you need to evaluate schema/=> or
schema/instrument as well.
- Remember to *var quote* when using schema/instrument.
- You must call "(status-im2.setup.schema/setup!)" after any var is
re-instrumented. It's advisable to add a keybinding in your editor to send
this expression automatically to the CLJS REPL, or add the call at the end of
the namespace you are working on (similar to how some devs add "(run-tests)"
at the end of test namespaces).
**Where should schemas be defined?**
For the moment, we should focus on instrumenting quo components, so define each
function schema in the same namespace as the component's public "view" var.
To be specific:
- A schema used only to instrument a single function and not used elsewhere,
like a quo component schema, wouldn't benefit from being defined in a separate
namespace because that would force the developer to constantly open two files
instead of one to check function signatures.
- A common schema reused across the repo, like ":schema.common/theme" should be
registered in the global registry "schema.registry" so that consumers can just
refer to it by keyword, as if it was a built-in malli schema.
- A common schema describing status-go entities like message, notification,
community, etc can be stored either in the respective
"src/status_im2/contexts/*" or registered globally, or even somewhere else.
This is yet to be defined, but since I chose not to include schemas for them,
we can postpone this guideline.
2023-11-18 14:04:48 +00:00
|
|
|
setupFilesAfterEnv: [
|
|
|
|
'@testing-library/jest-native/extend-expect',
|
|
|
|
'../component-spec/status_im2.setup.schema_preload.js',
|
|
|
|
'../test/jest/jestSetup.js',
|
|
|
|
],
|
2023-06-19 13:39:12 +00:00
|
|
|
setupFiles: [],
|
|
|
|
testPathIgnorePatterns: [],
|
|
|
|
moduleNameMapper: {
|
|
|
|
'^[@./a-zA-Z0-9$_-]+\\.(png|jpg|jpeg|gif)$':
|
|
|
|
'<rootDir>/../node_modules/react-native/Libraries/Image/RelativeImageStub',
|
|
|
|
},
|
|
|
|
testTimeout: 60000,
|
|
|
|
transformIgnorePatterns: [
|
2023-08-01 14:10:16 +00:00
|
|
|
'/node_modules/(?!(@react-native|react-native-haptic-feedback|react-native-redash|react-native-image-crop-picker|@react-native-community|react-native-linear-gradient|react-native-background-timer|react-native|rn-emoji-keyboard|react-native-languages|react-native-shake|react-native-reanimated|react-native-redash|react-native-permissions|@react-native-community/blur|react-native-static-safe-area-insets|react-native-gifted-charts)/).*/',
|
2023-06-19 13:39:12 +00:00
|
|
|
],
|
|
|
|
globals: {
|
|
|
|
__TEST__: true,
|
|
|
|
},
|
|
|
|
testEnvironment: 'node',
|
2023-08-01 14:10:16 +00:00
|
|
|
timers: 'fake',
|
2023-06-19 13:39:12 +00:00
|
|
|
rootDir: '../../component-spec',
|
|
|
|
testMatch: ['**/*__tests__*', '**/*.component_spec.js'],
|
2023-02-21 05:42:33 +00:00
|
|
|
};
|