Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brushing up the goodness! #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
21 changes: 12 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/dist/
/tmp/

# dependencies
/node_modules
/bower_components
/node_modules/
/bower_components/
/.node-version

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/connect.lock/
/coverage/
/*.log

# IDE
/.idea/
/*.iml
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"evil": true,
"forin": false,
"immed": false,
"laxbreak": false,
"laxbreak": true,
"newcap": true,
"noarg": true,
"noempty": false,
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ember-cli-mocha-reporter

Improved test reporter for ember-cli-mocha.
Improved test reporter for `ember-cli-mocha`.


## Installation

Expand All @@ -14,7 +15,7 @@ ember install ember-cli-mocha-reporter
Edit your `tests/test-helper.js` to add:

```javascript
import { mocha } from 'ember-mocha';
import { mocha } from 'mocha';
import Reporter from './helpers/ember-cli-mocha-reporter';

// ...
Expand All @@ -24,23 +25,22 @@ mocha.reporter(Reporter);

## Features

This adds the following features to ember-cli-mocha:
* Ember application container does not cover tests and slides in on hover.
* Code coverage support via ember-cli-blanket.
* No try/catch support so you can more easily debug your tests.

* Ember application container does not cover tests and slides in on hover (ef4)
* Code coverage support via ember-cli-blanket (SaladFork)
* No try/catch support so you can more easily debug your tests (lolmaus)

I fixed the following issues:
## Credit

* Made a proper Ember-CLI addon with minimal edits required to your project
* No longer requires a custom Bower install of the url.js library
* Fixed to work with the current url.js library as an NPM dependency
* Don't scale the progress canvas
Ember CLI addon assembled by [@mmelvin0](https://github.com/mmelvin0) with help of [contributors](https://github.com/mmelvin0/ember-cli-mocha-reporter/graphs/contributors).

Contains code borrowed from:

* [gist](https://github.com/ef4/better-mocha-html-reporter) by Edward Faulkner ([@ef4](https://github.com/ef4));
* [gist](https://gist.github.com/SaladFork/15683b00388bfe1d1458) by Elad Shahar ([@SaladFork](https://github.com/SaladFork));
* [gist](https://gist.github.com/lolmaus/8b5e84762c85142e43c2) by Andrey Mikhaylov ([@lolmaus](https://github.com/lolmaus)).

## Credit

This is based on the following code:
## License

* https://github.com/ef4/better-mocha-html-reporter
* https://gist.github.com/SaladFork/15683b00388bfe1d1458
* https://gist.github.com/lolmaus/8b5e84762c85142e43c2
MIT license.
8 changes: 1 addition & 7 deletions blueprints/ember-cli-mocha-reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ module.exports = {
},

afterInstall: function () {
// even with ember-browserify installed in both this addon and its parent
// it can't find the urljs library unless urljs is also installed in the parent
// see https://github.com/ef4/ember-browserify/issues/38
return this.addPackagesToProject([
{name: 'ember-browserify', target: '^1.1.9'},
{name: 'urljs', target: '^2.3.1'}
]);
return this.addBowerPackageToProject('url.js', 'jillix/url.js#^2.4.0');
}

};
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {

included: function (app) {
if (app.tests) {
app.import('bower_components/url.js/src/url.min.js', {type: 'test'});
app.import('vendor/ember-cli-mocha-reporter/test-container-styles.css', {type: 'test'});
}
}
Expand Down
24 changes: 17 additions & 7 deletions test-support/helpers/ember-cli-mocha-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* <https://github.com/mmelvin0/ember-cli-mocha-reporter>
*/

/* global $, Date */

import Url from 'npm:urljs';
/* global $, Date, Url */

// apparently Sinon can mess with the Date constructor
const OriginalDate = Date;
Expand Down Expand Up @@ -51,7 +49,15 @@ export default class Reporter {

$rootNode.append(template);

$('#test-title').text(document.title);
$('#test-title')
.text(document.title)
.on('click', e => {
e.preventDefault();
if (Url.queryString("grep")) {
Url.updateSearchParam("grep");
window.location.reload();
}
});

this.setupCanvas();

Expand All @@ -61,7 +67,7 @@ export default class Reporter {
this.$hidePassed = this.$stats.find('#hide-passed');

this.$hidePassed
.attr('checked', /hide_passed/.test(window.location.hash))
.attr('checked', /hidepassed/.test(window.location.hash))
.on('change', () => this.updateHidePassed());

this.updateHidePassed();
Expand Down Expand Up @@ -183,7 +189,7 @@ export default class Reporter {
if (this.$stats.find('#hide-passed').is(':checked')) {
$('#mocha-report').addClass('hide-passed');
$('#blanket-main').addClass('hide-passed');
window.location.hash = '#hide_passed';
window.location.hash = '#hidepassed';
} else {
$('#mocha-report').removeClass('hide-passed');
$('#blanket-main').removeClass('hide-passed');
Expand Down Expand Up @@ -241,6 +247,7 @@ export default class Reporter {
}

groupDescribes('JSHint');
groupDescribes('ESLint');
groupDescribes('JSCS');
}

Expand Down Expand Up @@ -470,11 +477,14 @@ function groupDescribes(linter) {
$suites.each((idx, suite) => {
let $suite = $(suite);
let suiteTitle = $suite.find('h1').text();
let [ , fileName] = suiteTitle.match(`^${linter} - (.*)$`);
let [,fileName] = suiteTitle.match(`^${linter} [\\|-] (.*)$`);

let $test = $suite.find('.test');

$test.find('.title').text(fileName);

$test.find('pre:eq(1)').hide();

$linter.find('ul').append($test);
$suite.remove();
});
Expand Down
22 changes: 15 additions & 7 deletions vendor/ember-cli-mocha-reporter/test-container-styles.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
html {
background: white;
}
#ember-testing-container {
position: fixed;
background: white;
bottom: 0;
right: -620px;
right: 0;
width: 640px;
height: 384px;
overflow: auto;
z-index: 101;
border: 1px solid #ccc;
transition: right 500ms;
transition: transform 500ms;
transform: translate3d(90%, 0, 0); /* create a new context to avoid fixed elements popping out */
}
#ember-testing-container:hover {
right: 0;
}
#ember-testing {
zoom: 50%;
height: 100%;
transform: translate3d(0, 0, 0);
}
#mocha {
margin: 60px 50px 15px 50px;
Expand Down Expand Up @@ -160,3 +160,11 @@ div #blanket-main .bl-error a {
#blanket-main .bl-source span {
text-align: right;
}

#mocha .test pre, #mocha .test pre.error {
width: 100%;
height: 100px;
max-height: none;
overflow: auto;
resize: vertical;
}
Loading