From 43cfa15d83d936afafb8a7b414d2b58ddf8b47fd Mon Sep 17 00:00:00 2001 From: Zack Sheppard Date: Tue, 2 Jul 2019 15:33:40 -0400 Subject: [PATCH 1/2] Add trailing `/` to `transformIgnorePatterns` Fix a small bug with the `transformIgnorePatterns` suggested fix for performing proper transformations on the mocks for Jest compatibility. Need to add a trailing `/` to the regex for the transform ignore, otherwise it will match all packages in `node-modules` that start with the string `react-native`! --- docs/Jest-integration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Jest-integration.md b/docs/Jest-integration.md index 79f60bad..d12c133b 100644 --- a/docs/Jest-integration.md +++ b/docs/Jest-integration.md @@ -82,6 +82,6 @@ Optionally, you can transform whole scope for `react-native-community` and `reac ```json "jest": { - "transformIgnorePatterns": ["node_modules/(?!(@react-native-community|react-native))"] + "transformIgnorePatterns": ["node_modules/(?!(@react-native-community|react-native)/)"] } -``` \ No newline at end of file +``` From 8e9413e267973985c4a8e9debd58b8aab581d571 Mon Sep 17 00:00:00 2001 From: Zack Sheppard Date: Tue, 2 Jul 2019 17:07:48 -0400 Subject: [PATCH 2/2] Further explanation about the transform regex As suggested by @thymikee --- docs/Jest-integration.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Jest-integration.md b/docs/Jest-integration.md index d12c133b..d9000440 100644 --- a/docs/Jest-integration.md +++ b/docs/Jest-integration.md @@ -71,17 +71,18 @@ You can [check its implementation](../jest/async-storage-mock.js) to get more in You need to point Jest to transform this package. You can do so, by adding Async Storage path to `transformIgnorePatterns` setting in Jest's configuration. - ```json "jest": { "transformIgnorePatterns": ["node_modules/(?!(@react-native-community/async-storage/lib))"] } ``` -Optionally, you can transform whole scope for `react-native-community` and `react-native`: +Optionally, you can transform all packages in the `react-native-community` and `react-native` directories by specifying this pattern: ```json "jest": { "transformIgnorePatterns": ["node_modules/(?!(@react-native-community|react-native)/)"] } ``` + +Or you can expand it even further to transform all packages whose names begin with `react-native` by omitting the trailing `/` in the above pattern.