UNPKG

1.93 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10var lowPriorityWarning = function lowPriorityWarning() {};
11
12if (process.env.NODE_ENV !== 'production') {
13 var printWarning = function(format) {
14 for (
15 var _len = arguments.length,
16 args = Array(_len > 1 ? _len - 1 : 0),
17 _key = 1;
18 _key < _len;
19 _key++
20 ) {
21 args[_key - 1] = arguments[_key];
22 }
23
24 var argIndex = 0;
25 var message =
26 'Warning: ' +
27 format.replace(/%s/g, function() {
28 return args[argIndex++];
29 });
30 if (typeof console !== 'undefined') {
31 console.warn(message);
32 }
33 try {
34 // --- Welcome to debugging React ---
35 // This error was thrown as a convenience so that you can use this stack
36 // to find the callsite that caused this warning to fire.
37 throw new Error(message);
38 } catch (x) {}
39 };
40
41 lowPriorityWarning = function(condition, format) {
42 if (format === undefined) {
43 throw new Error(
44 '`warning(condition, format, ...args)` requires a warning ' +
45 'message argument'
46 );
47 }
48 if (!condition) {
49 for (
50 var _len2 = arguments.length,
51 args = Array(_len2 > 2 ? _len2 - 2 : 0),
52 _key2 = 2;
53 _key2 < _len2;
54 _key2++
55 ) {
56 args[_key2 - 2] = arguments[_key2];
57 }
58
59 printWarning.apply(undefined, [format].concat(args));
60 }
61 };
62}
63
64// This package has been deprecated in NPM as of version 15.5.0
65// But NPM deprecation warnings are easy to overlook
66// So a more explicit runtime warning seemed appropriate
67lowPriorityWarning(
68 false,
69 'ReactTestUtils has been moved to react-dom/test-utils. ' +
70 'Update references to remove this warning.'
71);
72
73module.exports = require('react-dom/lib/ReactTestUtils');