react / wstein / node_modules / browserify / node_modules / console-browserify / test / static / test-adapter.js
80536 views(function () {1var Testem = window.Testem2var regex = /^((?:not )?ok) (\d+) (.+)$/34Testem.useCustomAdapter(tapAdapter)56function tapAdapter(socket){7var results = {8failed: 09, passed: 010, total: 011, tests: []12}1314socket.emit('tests-start')1516Testem.handleConsoleMessage = function(msg){17var m = msg.match(regex)18if (m) {19var passed = m[1] === 'ok'20var test = {21passed: passed ? 1 : 0,22failed: passed ? 0 : 1,23total: 1,24id: m[2],25name: m[3],26items: []27}2829if (passed) {30results.passed++31} else {32console.error("failure", m)3334results.failed++35}3637results.total++3839// console.log("emitted test", test)40socket.emit('test-result', test)41results.tests.push(test)42} else if (msg === '# ok' || msg.match(/^# tests \d+/)){43// console.log("emitted all test")44socket.emit('all-test-results', results)45}4647// return false if you want to prevent the console message from48// going to the console49// return false50}51}52}())535455