react-native/IntegrationTests/LoggingTestModule.js
Douglas Lowder bdff1c3f02 Fix timing issues in RCTLoggingTests.m
Summary:
**Motivation**

If there are any console log messages that come in on initialization (as will happen right now in tvOS), the RCTLoggingTests can fail intermittently.  This change delays the start of the logging test to allow time for initial console messages to come in.
Closes https://github.com/facebook/react-native/pull/10568

Differential Revision: D4087974

Pulled By: bestander

fbshipit-source-id: 2b0f4a88a74bc6121133317dd909d5bd1f10789b
2016-10-27 01:43:34 -07:00

47 lines
1.1 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule LoggingTestModule
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var warning = require('fbjs/lib/warning');
var invariant = require('fbjs/lib/invariant');
var LoggingTestModule = {
logToConsole: function(str) {
console.log(str);
},
logToConsoleAfterWait: function(str,timeout_ms) {
setTimeout(function() {
console.log(str);
}, timeout_ms);
},
warning: function(str) {
warning(false, str);
},
invariant: function(str) {
invariant(false, str);
},
logErrorToConsole: function(str) {
console.error(str);
},
throwError: function(str) {
throw new Error(str);
}
};
BatchedBridge.registerCallableModule(
'LoggingTestModule',
LoggingTestModule
);
module.exports = LoggingTestModule;