mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
enable coverage logging from the worker
This commit is contained in:
@@ -31,6 +31,8 @@ describe('ReactWebWorker', function() {
|
||||
var data = JSON.parse(e.data);
|
||||
if (data.type == 'error') {
|
||||
error = data.message + "\n" + data.stack;
|
||||
} else if (data.type == 'log') {
|
||||
console.log(data.message);
|
||||
} else {
|
||||
expect(data.type).toBe('done');
|
||||
done = true;
|
||||
@@ -42,7 +44,7 @@ describe('ReactWebWorker', function() {
|
||||
});
|
||||
runs(function() {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
throw new Error(error);
|
||||
}
|
||||
});
|
||||
|
||||
+23
-5
@@ -1,6 +1,26 @@
|
||||
/* jshint worker: true */
|
||||
"use strict";
|
||||
|
||||
if (typeof console == 'undefined') {
|
||||
this.console = {
|
||||
error: function(e){
|
||||
postMessage(JSON.stringify({
|
||||
type: 'error',
|
||||
message: e.message,
|
||||
stack: e.stack
|
||||
}));
|
||||
},
|
||||
log: function(message){
|
||||
postMessage(JSON.stringify({
|
||||
type: 'log',
|
||||
message: message
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('worker BEGIN');
|
||||
|
||||
// The UMD wrapper tries to store on `global` if `window` isn't available
|
||||
var global = {};
|
||||
importScripts("phantomjs-shims.js");
|
||||
@@ -8,13 +28,11 @@ importScripts("phantomjs-shims.js");
|
||||
try {
|
||||
importScripts("../../build/react.js");
|
||||
} catch (e) {
|
||||
postMessage(JSON.stringify({
|
||||
type: 'error',
|
||||
message: e.message,
|
||||
stack: e.stack
|
||||
}));
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
postMessage(JSON.stringify({
|
||||
type: 'done'
|
||||
}));
|
||||
|
||||
console.log('worker END');
|
||||
|
||||
Reference in New Issue
Block a user