diff --git a/package.json b/package.json index 2fc2d0b10..b5898b092 100644 --- a/package.json +++ b/package.json @@ -289,7 +289,7 @@ "LiveScript": "^1.3.0", "babel": "^5.6.23", "babel-eslint": "^4.1.8", - "chai": "^3.3.0", + "chai": "^3.5.0", "chai-as-promised": "^5.0.0", "chai-subset": "^1.0.1", "coffee-script": "^1.9.2", @@ -315,6 +315,7 @@ "json3": "^3.3.2", "karma-browserify": "^5.0.1", "karma-browserstack-launcher": "^0.1.10", + "karma-chai": "^0.1.0", "karma-chrome-launcher": "*", "karma-coffee-preprocessor": "*", "karma-commonjs": "*", @@ -326,6 +327,7 @@ "karma-junit-reporter": "*", "karma-live-preprocessor": "*", "karma-mocha": "0.2.1", + "karma-mocha-reporter": "^1.2.0", "karma-ng-scenario": "*", "karma-phantomjs-launcher": "*", "karma-qunit": "*", diff --git a/test/e2e/mocharepoter.feature b/test/e2e/mocharepoter.feature new file mode 100644 index 000000000..92261509f --- /dev/null +++ b/test/e2e/mocharepoter.feature @@ -0,0 +1,48 @@ +Feature: Mocha reporter + In order to use Karma + As a person who wants to write great tests + I want to be able to use the mocha reporter. + + Scenario: Execute a test in PhantomJS with colors + Given a configuration with: + """ + files = ['mocha/plus.js', 'mocha/test.js']; + browsers = ['PhantomJS']; + frameworks = ['mocha', 'chai'] + colors = true + plugins = [ + 'karma-jasmine', + 'karma-phantomjs-launcher', + 'karma-mocha-reporter', + 'karma-mocha', + 'karma-chai' + ]; + reporters = ['mocha']; + """ + When I start Karma + Then it passes with like: + """ + 2 tests completed + """ + + Scenario: Execute a test in PhantomJS with no-colors + Given a configuration with: + """ + files = ['mocha/plus.js', 'mocha/test.js']; + browsers = ['PhantomJS']; + frameworks = ['mocha', 'chai'] + colors = false + plugins = [ + 'karma-jasmine', + 'karma-phantomjs-launcher', + 'karma-mocha-reporter', + 'karma-mocha', + 'karma-chai' + ]; + reporters = ['mocha']; + """ + When I start Karma + Then it passes with like: + """ + ✔ 2 tests completed + """ \ No newline at end of file diff --git a/test/e2e/steps/core_steps.js b/test/e2e/steps/core_steps.js index 6416a7a8c..400df1e9b 100644 --- a/test/e2e/steps/core_steps.js +++ b/test/e2e/steps/core_steps.js @@ -107,11 +107,10 @@ module.exports = function coreSteps () { })(this)) }) - this.Then(/^it passes with( no debug)?:$/, {timeout: 10 * 1000}, function (noDebug, expectedOutput, callback) { - noDebug = noDebug === ' no debug' + this.Then(/^it passes with( no debug| like)?:$/, {timeout: 10 * 1000}, function (mode, expectedOutput, callback) { + var noDebug = mode === ' no debug' + var like = mode === ' like' var actualOutput = this.lastRun.stdout.toString() - var actualError = this.lastRun.error - var actualStderr = this.lastRun.stderr.toString() var lines if (noDebug) { @@ -121,11 +120,15 @@ module.exports = function coreSteps () { actualOutput = lines.join('\n') } + if (like && actualOutput.indexOf(expectedOutput) >= 0) { + return callback() + } + if (actualOutput.indexOf(expectedOutput) === 0) { return callback() } - if (actualError || actualStderr) { + if (actualOutput) { return callback(new Error('Expected output to match the following:\n ' + expectedOutput + '\nGot:\n ' + actualOutput)) } diff --git a/test/e2e/support/mocha/plus.js b/test/e2e/support/mocha/plus.js new file mode 100644 index 000000000..d7fd9e84e --- /dev/null +++ b/test/e2e/support/mocha/plus.js @@ -0,0 +1,5 @@ +/* eslint-disable no-unused-vars */ +// Some code under test +function plus (a, b) { + return a + b +} diff --git a/test/e2e/support/mocha/test.js b/test/e2e/support/mocha/test.js new file mode 100644 index 000000000..2f0dde3ab --- /dev/null +++ b/test/e2e/support/mocha/test.js @@ -0,0 +1,10 @@ +/* globals plus */ +describe('plus', function () { + it('should pass', function () { + expect(true).to.be.true + }) + + it('should work', function () { + expect(plus(1, 2)).to.equal(3) + }) +})