@sentry/wizard 3.22.2 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,9 @@ import * as Sentry from '@sentry/react-native';
31
31
 
32
32
  Sentry.init({
33
33
  dsn: 'dsn',
34
+
35
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
36
+ // enableSpotlight: __DEV__,
34
37
  });
35
38
 
36
39
  const App = () => {
@@ -9,11 +9,124 @@ import {
9
9
  addSentrySerializerRequireToMetroConfig,
10
10
  addSentrySerializerToMetroConfig,
11
11
  getMetroConfigObject,
12
+ patchMetroWithSentryConfigInMemory,
12
13
  removeSentryRequire,
13
14
  removeSentrySerializerFromMetroConfig,
14
15
  } from '../../src/react-native/metro';
15
16
 
16
17
  describe('patch metro config - sentry serializer', () => {
18
+ describe('patchMetroWithSentryConfigInMemory', () => {
19
+ it('patches react native 0.72 default metro config', async () => {
20
+ const mod =
21
+ parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
22
+
23
+ /**
24
+ * Metro configuration
25
+ * https://reactnative.dev/docs/metro
26
+ *
27
+ * @type {import('metro-config').MetroConfig}
28
+ */
29
+ const config = {};
30
+
31
+ module.exports = mergeConfig(getDefaultConfig(__dirname), config);`);
32
+
33
+ const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
34
+ /* noop */
35
+ });
36
+ expect(result).toBe(true);
37
+ expect(generateCode(mod.$ast).code)
38
+ .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
39
+
40
+ const {
41
+ withSentryConfig
42
+ } = require("@sentry/react-native/metro");
43
+
44
+ /**
45
+ * Metro configuration
46
+ * https://reactnative.dev/docs/metro
47
+ *
48
+ * @type {import('metro-config').MetroConfig}
49
+ */
50
+ const config = {};
51
+
52
+ module.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);
53
+ });
54
+
55
+ it('patches react native 0.65 default metro config', async () => {
56
+ const mod = parseModule(`/**
57
+ * Metro configuration for React Native
58
+ * https://github.com/facebook/react-native
59
+ *
60
+ * @format
61
+ */
62
+
63
+ module.exports = {
64
+ transformer: {
65
+ getTransformOptions: async () => ({
66
+ transform: {
67
+ experimentalImportSupport: false,
68
+ inlineRequires: true,
69
+ },
70
+ }),
71
+ },
72
+ };`);
73
+
74
+ const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
75
+ /* noop */
76
+ });
77
+ expect(result).toBe(true);
78
+ expect(generateCode(mod.$ast).code).toBe(`const {
79
+ withSentryConfig
80
+ } = require("@sentry/react-native/metro");
81
+
82
+ /**
83
+ * Metro configuration for React Native
84
+ * https://github.com/facebook/react-native
85
+ *
86
+ * @format
87
+ */
88
+
89
+ module.exports = withSentryConfig({
90
+ transformer: {
91
+ getTransformOptions: async () => ({
92
+ transform: {
93
+ experimentalImportSupport: false,
94
+ inlineRequires: true,
95
+ },
96
+ }),
97
+ },
98
+ });`);
99
+ });
100
+
101
+ it('patches react native metro config exported variable', async () => {
102
+ const mod = parseModule(`const testConfig = {};
103
+
104
+ module.exports = testConfig;`);
105
+
106
+ const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
107
+ /* noop */
108
+ });
109
+ expect(result).toBe(true);
110
+ expect(generateCode(mod.$ast).code).toBe(`const {
111
+ withSentryConfig
112
+ } = require("@sentry/react-native/metro");
113
+
114
+ const testConfig = {};
115
+
116
+ module.exports = withSentryConfig(testConfig);`);
117
+ });
118
+
119
+ it('does not patch react native metro config exported as factory function', async () => {
120
+ const mod = parseModule(`module.exports = () => ({});`);
121
+
122
+ const result = await patchMetroWithSentryConfigInMemory(mod, async () => {
123
+ /* noop */
124
+ });
125
+ expect(result).toBe(false);
126
+ expect(generateCode(mod.$ast).code).toBe(`module.exports = () => ({});`);
127
+ });
128
+ });
129
+
17
130
  describe('addSentrySerializerToMetroConfig', () => {
18
131
  it('add to empty config', () => {
19
132
  const mod = parseModule(`module.exports = {