Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
// iniitial logz
const { rawLogz } = this.props
// also listen
Hook(window.console, (log) => {
this.setState((state) => {
var logz = state.logs.slice()
logz.push(Decode(log))
return {
logs: logz
}
})
})
// replay initial logs
console.log(...rawLogz)
}
handleMessage = data => {
switch (data.type) {
case 'console': {
const message = Decode(data.log);
const { method, data: args } = message;
switch (method) {
case 'clear': {
// If the event was done by the packager
const hideMessage = args && args[0] === '__internal__';
this.clearConsole(hideMessage);
break;
}
default: {
this.addMessage(method, args);
break;
}
}
break;
handleMessage = data => {
switch (data.type) {
case 'console': {
const message = Decode(data.log);
const { method, data: args } = message;
switch (method) {
case 'clear': {
// If the event was done by the packager
const hideMessage = args && args[0] === '__internal__';
this.clearConsole(hideMessage);
break;
}
default: {
this.addMessage(method, args);
break;
}
}
break;
handleMessage = data => {
switch (data.type) {
case 'console': {
const message = Decode(data.log);
const {method, data: args} = message;
switch (method) {
case 'clear': {
// If the event was done by the packager
const hideMessage = args && args[0] === '__internal__';
this.clearConsole(hideMessage);
break;
}
default: {
this.addMessage(method, args);
break;
}
}
break;
initializeResizeListener();
}
// Testing
const ttt = Date.now();
const testRunner = manager.testRunner;
try {
testRunner.initialize();
testRunner.findTests(modules);
await testRunner.runTests();
const aggregatedResults = testRunner.reportResults();
debug(`Test Evaluation time: ${Date.now() - ttt}ms`);
dispatch({
type: 'test-result',
result: Encode(aggregatedResults),
});
// End - Testing
} catch (error) {
dispatch({
type: 'test-result',
error: testRunner.reportError(error),
});
}
debug(`Total time: ${Date.now() - startTime}ms`);
dispatch({
type: 'success',
});
firstLoad = false;
setLogs(logs => ([Decode(log), ...logs]))
})
case 'eval-result': {
const { result, error } = data;
const decoded = Decode(result);
if (!error) {
this.addMessage('result', [decoded]);
} else {
this.addMessage('error', [decoded]);
}
break;
}
case 'test-result': {
const { result, error } = data;
const aggregatedResults = Decode(result);
if (!error) {
if (aggregatedResults) {
const { summaryMessage, failedMessages } = aggregatedResults;
this.addMessage('log', [summaryMessage]);
failedMessages.forEach(t => {
this.addMessage('warn', [t]);
});
} else {
this.addMessage('warn', [undefined]);
}
} else {
this.addMessage('error', [error]);
}
break;
}
case 'search-log': {
case 'eval-result': {
const {result, error} = data;
const decoded = Decode(result);
if (!error) {
this.addMessage('result', [decoded]);
} else {
this.addMessage('error', [decoded]);
}
break;
}
case 'test-result': {
const {result, error} = data;
const aggregatedResults = Decode(result);
if (!error) {
if (aggregatedResults) {
const {summaryMessage, failedMessages} = aggregatedResults;
this.addMessage('log', [summaryMessage]);
failedMessages.forEach(t => {
this.addMessage('warn', [t]);
});
} else {
this.addMessage('warn', [undefined]);
}
} else {
this.addMessage('error', [error]);
}
break;
}
default: {
break;
}
case 'clear-console': {
if (this.state.initialClear) {
this.setState({
initialClear: false,
});
} else {
this.clearConsole();
}
break;
}
case 'eval-result': {
const { result, error } = data;
const decoded = Decode(result);
if (!error) {
this.addMessage('result', [decoded]);
} else {
this.addMessage('error', [decoded]);
}
break;
}
case 'test-result': {
const { result, error } = data;
const aggregatedResults = Decode(result);
if (!error) {
if (aggregatedResults) {
const { summaryMessage, failedMessages } = aggregatedResults;
this.addMessage('log', [summaryMessage]);
this.setState((state) => {
var logz = state.logs.slice()
logz.push(Decode(log))
return {
logs: logz
}
})