* Added JS code for Sentry * Removed leftover initializeSentry call * Added SentryOptions config setting * Added native components for react-native-exception-handler * Removed default props from ErrorText * Moved where Sentry is initialized * Added ios/sentry.properties to .gitignore * Added linking react-native-sentry to Fastlane * Fixed fastlane to include newlines in sentry.properties * Moved to manually link react-native-sentry * Captured redux errors with Sentry * Redid how Sentry is optionally compiled to be simpler * Added Sentry middleware to create redux breadcrumbs * Added Sentry tags for server version * Initialize Sentry when testing * Fixed string replacement for SentryEnabled in fastlane * Added react-native-sentry to NOTICE.txt
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
// Setup recommendation from the following blog:
|
|
// https://blog.addjam.com/testing-react-native-with-mocha-and-enzyme-6b77cd9e52a1#.2awpwqwwb
|
|
|
|
/* eslint-disable */
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import register from 'babel-core/register';
|
|
import chai from 'chai';
|
|
import chaiEnzyme from 'chai-enzyme';
|
|
import ReactNative from 'react-native-mock';
|
|
import {Sentry} from 'react-native-sentry';
|
|
|
|
const m = require('module');
|
|
const originalLoader = m._load;
|
|
|
|
const NativeModules = ReactNative.NativeModules;
|
|
const Platform = ReactNative.Platform;
|
|
|
|
NativeModules.RNCookieManagerIOS = {};
|
|
NativeModules.RNCookieManagerAndroid = {};
|
|
|
|
Platform.__setOS('ios');
|
|
|
|
// Image file ignore setup from:
|
|
// http://valuemotive.com/2016/08/01/unit-testing-react-native-components-with-mocha-and-enzyme/
|
|
m._load = function hookedLoader(request, parent, isMain) {
|
|
if (request.match(/.jpeg|.jpg|.png$/)) {
|
|
return {uri: request}
|
|
}
|
|
|
|
return originalLoader(request, parent, isMain);
|
|
};
|
|
|
|
// Ignore all node_modules except these
|
|
const modulesToCompile = [
|
|
'react-native',
|
|
'react-native-mock',
|
|
'react-native-svg-mock/mock',
|
|
'react-native-vector-icons',
|
|
'react-native-svg'
|
|
].map((moduleName) => new RegExp(`/node_modules/${moduleName}`));
|
|
|
|
const rcPath = path.join(__dirname, '..', '.babelrc');
|
|
const source = fs.readFileSync(rcPath).toString();
|
|
const config = JSON.parse(source);
|
|
config.ignore = function(filename) {
|
|
if (!(/\/node_modules\//).test(filename)) {
|
|
return false;
|
|
}
|
|
|
|
const matches = modulesToCompile.filter((regex) => regex.test(filename));
|
|
const shouldIgnore = matches.length === 0;
|
|
return shouldIgnore;
|
|
};
|
|
|
|
register(config);
|
|
|
|
chai.use(chaiEnzyme());
|
|
|
|
// Initialize Sentry so that it doesn't complain when the middleware tries to create breadcrumbs
|
|
Sentry.config('');
|