| 53 | } |
| 54 | |
| 55 | function runTest(test, continuation) { |
| 56 | try { |
| 57 | var afterTests = []; |
| 58 | |
| 59 | for (var i = 0; i < superFixtures.length; ++i) { |
| 60 | var superFixture = superFixtures[i]; |
| 61 | |
| 62 | var superScope = {}; |
| 63 | superFixture.beforeTest.call(superScope); |
| 64 | afterTests.push(superFixture.afterTest.bind(superScope)); |
| 65 | } |
| 66 | |
| 67 | var testScope = test.fixture ? |
| 68 | Object.create(test.fixture.scope) : |
| 69 | {}; |
| 70 | |
| 71 | var runSetUp = function(fixtureObject) { |
| 72 | if (undefined === fixtureObject) { |
| 73 | return; |
| 74 | } |
| 75 | runSetUp(fixtureObject.parent); |
| 76 | fixtureObject.setUp.call(testScope); |
| 77 | afterTests.push(fixtureObject.tearDown.bind(testScope)); |
| 78 | }; |
| 79 | runSetUp(test.fixture); |
| 80 | |
| 81 | test.body.call(testScope); |
| 82 | while (afterTests.length) { |
| 83 | afterTests.pop()(); |
| 84 | } |
| 85 | return false; |
| 86 | } catch (e) { |
| 87 | console.error(e.stack); |
| 88 | console.error('error:', e); |
| 89 | return {stack: e.stack, e: e}; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function run_tests(reporter, filter = undefined) { |
| 94 | let testsToRun = allTests; |