ember-test-utils provides a set of utilities to help you in testing Ember modules. This library requires you
use ember-mocha as your testing framework. It provides shortcuts for working with:
A helper to allow easy testing of the component dependency injection pattern. This helper will create a mock component
with the default name mock-component. The name can be set by passing a String <name> as the second parameter.
The third parameter allows you to pass any properties into the component as an Object {classNames: 'my-classname'}.
Credit goes to poteto for the initial implementation of this idea.
<h2>A component to demonstrate the mock component helper</h2>
Out of box having ember-test-utils in your project will make your vendor.js asset slightly larger, as of 2017-02-15
this increase in size is approximately 0.08 KB. If you want to keep this out of your build for certain environments
you can add the following configuration to your package.json:
{
"ember-test-utils":{
"excludeFromEnvironments":["production"]
}
}
Custom Mocha Reporter
If you'd like to use the custom Mocha reporter provided by this addon then your testem.js file should look something
like this:
var Reporter =require('ember-test-utils/reporter')
module.exports={
disable_watching:true,
framework:'mocha',
launch_in_ci:[
'Chrome'
],
launch_in_dev:[
'Chrome'
],
reporter:newReporter(),
test_page:'tests/index.html?hidepassed'
}
NOTE: This reporter will group test results into two sections: failed and passed. Each section is sorted from slowest
test to fastest test so you can see which tests are causing your CI to come to a crawl.
Linting
All File Types
If you want to lint your Dockerfile's, templates, Javascript, Markdown, and SASS
files you can simply run:
./node_modules/.bin/lint-all-the-things
or even better add the following script to your package.json:
{
"scripts":{
"lint":"lint-all-the-things"
}
}
and run
npm run lint-all-the-things
Many eslint errors and warnings can be automatically fixed using the --fix command line argument. For example,
./node_modules/.bin/lint-all-the-things --fix
npm run lint-all-the-things -- --fix
Dockerfile
If you want to lint your template files you can simply run:
./node_modules/.bin/lint-docker
or even better add the following script to your package.json:
{
"scripts":{
"lint-docker":"lint-docker"
}
}
and run
npm run lint-docker
Javascript
If you want to lint your Javascript files you can simply run:
./node_modules/.bin/lint-javascript
or even better add the following script to your package.json:
{
"scripts":{
"lint-js":"lint-javascript"
}
}
and run
npm run lint-js
If you would like any Javascript files to be ignored during linting simply create a .eslintignore file in the root
of your project and populate it with one
glob pattern per line.
Markdown
If you want to lint your Markdown files you can simply run:
./node_modules/.bin/lint-markdown
or even better add the following script to your package.json:
{
"scripts":{
"lint-md":"lint-markdown"
}
}
and run
npm run lint-md
If you would like any Markdown files to be ignored during linting simply create a .remarkignore file in the root
of your project and populate it with one
glob pattern per line.
Stylesheets (SASS)
If you want to lint your SASS files you can simply run:
./node_modules/.bin/lint-sass
or even better add the following script to your package.json:
{
"scripts":{
"lint-sass":"lint-sass"
}
}
and run
npm run lint-hbs
Templates (HTMLBars)
If you want to lint your template files you can simply run:
./node_modules/.bin/lint-htmlbars
or even better add the following script to your package.json:
{
"scripts":{
"lint-hbs":"lint-htmlbars"
}
}
and run
npm run lint-hbs
By default the
recommended ember-template-lint
rules are enforced. If you would like to enable/disable other rules, you can do so by creating a
.template-lintrc.js file in the root of your project per
these instructions.
Contributing
This following outlines the details of collaborating on this Ember addon:
Installation
git clone this repository
npm install
bower install
Running Tests
npm test (Runs ember try:testall to test your addon against multiple Ember versions)