Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ sudo: false

cache:
yarn: true
directories:
- $HOME/.cache # includes bowers cache

env:
- EMBER_TRY_SCENARIO=ember-lts-2.4
Expand All @@ -26,13 +24,11 @@ matrix:
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add bower phantomjs-prebuilt
- bower --version
- yarn global add phantomjs-prebuilt
- phantomjs --version

install:
- yarn install --no-lockfile
- bower install

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
Expand Down
6 changes: 0 additions & 6 deletions bower.json

This file was deleted.

177 changes: 4 additions & 173 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,185 +3,16 @@
/* eslint-env node */

var path = require('path');
var fs = require('fs');
var MergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
var resolve = require('resolve');

module.exports = {
name: 'ember-cli-mocha',

overrideTestCommandFilter: function() {
var TestCommand = this.project.require('ember-cli/lib/commands/test');

TestCommand.prototype.buildTestPageQueryString = function(options) {
var params = [];

if (options.filter) {
params.push('grep=' + options.filter);

if (options.invert) {
params.push('invert=1');
}
}

if (options.query) {
params.push(options.query);
}

return params.join('&');
};

TestCommand.prototype.availableOptions.push({
name: 'invert',
type: Boolean,
default: false,
description: 'Invert the filter specified by the --filter argument',
aliases: ['i']
});
contentFor(type) {
let output = this.eachAddonInvoke('contentFor', [type]);
return output.join('\n');
},

_getDependencyTrees: function() {
if (this._dependencyTrees) {
return this._dependencyTrees;
}

var emberTestHelpersPath = path.dirname(resolve.sync('ember-test-helpers', { basedir: this._emberMochaLibPath }));
this._dependencyTrees = [
this.treeGenerator(this._emberMochaLibPath),
this.treeGenerator(emberTestHelpersPath),
];

return this._dependencyTrees;
},

init: function() {
this._super.init && this._super.init.apply(this, arguments);

this.overrideTestCommandFilter();

this._emberMochaLibPath = path.dirname(resolve.sync('ember-mocha'));
this._shouldPreprocessAddonTestSupport = !!this.options && !!this.options.babel;

this.setTestGenerator();
},

postBuild: function () {
this.checkPackages();
},

checkPackages: function () {
var packages = Object.keys(this.project.addonPackages);
if (packages.indexOf('ember-cli-qunit') !== -1) {
console.warn('\nIt looks like you are using "ember-cli-qunit" which can cause issues with "ember-cli-mocha", please remove this package.\n');
process.exit(1);
}
if (packages.indexOf('ember-cli-htmlbars-inline-precompile') < 0) {
console.warn('\nIt looks like you\'re not on ember-cli 1.13, which includes ember-cli-htmlbars-inline-precompile by default. Please run: ember install ember-cli-htmlbars-inline-precompile.\n');
process.exit(1);
}
},

blueprintsPath: function() {
blueprintsPath() {
return path.join(__dirname, 'blueprints');
},

treeForVendor: function(tree) {
var mochaPath = path.dirname(resolve.sync('mocha'));
// var mochaTree = this.treeGenerator(mochaPath);
var mochaTree = new Funnel(mochaPath, {
files: ['mocha.js', 'mocha.css'],
destDir: '/mocha',
});

var emberMochaBuildSupportPath = path.join(this._emberMochaLibPath, '..', 'build-support');

var mochaSetupTree = new Funnel(emberMochaBuildSupportPath, {
files: ['mocha-setup.js', 'ember-mocha-adapter.js'],
destDir: '/ember-mocha'
});

var trees = [
tree,
mochaTree,
mochaSetupTree
];

return new MergeTrees(trees, {
annotation: 'ember-cli-mocha: treeForVendor'
});
},

treeForAddonTestSupport: function() {
var tree = new MergeTrees(this._getDependencyTrees());

if (this._shouldPreprocessAddonTestSupport) {
return this.preprocessJs(tree, {
registry: this.registry
});
} else {
return tree;
}
},

included: function included(app, parentAddon) {
var target = (parentAddon || app);
this._super.included.call(this, target);

if (app.tests) {
var fileAssets = [
'vendor/mocha/mocha.js',
'vendor/mocha/mocha.css',
'vendor/ember-mocha/mocha-setup.js',
'vendor/ember-mocha/ember-mocha-adapter.js',
'vendor/ember-cli-mocha/test-loader.js'
];

var addonOptions = app.options['ember-cli-mocha'] || {};
if (addonOptions && !addonOptions.disableContainerStyles) {
fileAssets.push('vendor/ember-cli-mocha/test-container-styles.css');
}

fileAssets.forEach(function(file){
app.import(file, {
type: 'test'
});
});
}
},

contentFor: function(type) {
if (type === 'test-body') {
return this._readTemplate('test-body');
}
},

_readTemplate: function(name) {
return fs.readFileSync(path.join(__dirname, 'templates', name + '.html'));
},

setTestGenerator: function() {
this.project.generateTestFile = function(moduleName, tests) {
var output = "describe('" + moduleName + "', function() {\n";

tests.forEach(function(test) {
output += " it('" + test.name + "', function() {\n";
if (test.passed) {
output +=
" // precompiled test passed\n";
} else {
output +=
" // precompiled test failed\n" +
" var error = new chai.AssertionError('" + test.errorMessage + "');\n" +
" error.stack = undefined;\n" +
" throw error;\n";
}
output += " });\n";
});

output += "});\n";

return output;
};
}
};
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@
"test": "ember try:each"
},
"dependencies": {
"broccoli-funnel": "^2.0.0",
"broccoli-merge-trees": "^2.0.0",
"ember-cli-babel": "^6.0.0",
"ember-cli-test-loader": "^2.0.0",
"ember-mocha": "^0.12.0",
"mocha": "^2.5.3",
"resolve": "^1.1.7"
"ember-mocha": "^0.13.0-beta.1"
},
"devDependencies": {
"ember-cli": "~2.16.0",
"ember-cli-babel": "^6.0.0",
"ember-cli-chai": "^0.4.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.0.0",
Expand Down
6 changes: 0 additions & 6 deletions templates/test-body.html

This file was deleted.

42 changes: 0 additions & 42 deletions tests/unit/test-loader-test.js

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/ember-cli-mocha/test-container-styles.css

This file was deleted.

31 changes: 0 additions & 31 deletions vendor/ember-cli-mocha/test-loader.js

This file was deleted.

Loading