Skip to content

Commit

Permalink
test(reporter): Add mocha test
Browse files Browse the repository at this point in the history
 Add a test of the karma-mocha-reporter. Testing that it outputs
 correctly.
  • Loading branch information
budde377 authored and danielcompton committed Jun 20, 2016
1 parent f4e8eb2 commit 37437ba
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,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": "*",
Expand All @@ -327,6 +328,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": "*",
Expand Down
48 changes: 48 additions & 0 deletions test/e2e/mocharepoter.feature
Original file line number Diff line number Diff line change
@@ -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
"""
2 changes: 1 addition & 1 deletion test/e2e/steps/core_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module.exports = function coreSteps () {
return callback()
}

if (actualOutput.indexOf(expectedOutput) >= 0) {
if (actualOutput.indexOf(expectedOutput) === 0) {
return callback()
}

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/support/mocha/plus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable no-unused-vars */
// Some code under test
function plus (a, b) {
return a + b
}
10 changes: 10 additions & 0 deletions test/e2e/support/mocha/test.js
Original file line number Diff line number Diff line change
@@ -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)
})
})

0 comments on commit 37437ba

Please sign in to comment.