ember-cli-blueprint-test-helpers
test helpers for ember-cli blueprints
Installation
ember install ember-cli-blueprint-test-helpers
It should be noted that ember-cli-blueprint-test-helpers
currently
only works for testing blueprints inside addon projects.
Usage
Running Tests
The blueprint tests can be run by:
node_modules/.bin/mocha node-tests --recursive
For convenience you should add the following to your package.json
:
"scripts":
to be able to use npm run nodetest
to run the tests.
Generating Tests
Generate a blueprint test scaffold using the blueprint-test
generator:
ember generate blueprint-test my-blueprint
which will generate a test file at node-tests/blueprints/my-blueprint-test.js
.
Example Usage
;
or more explicitly:
;
if your blueprints support the new
MU file structure, you can test them
using this option: { ìsModuleUnification: true }
;
API Reference
This project exports two major API endpoints for you to use:
-
require('ember-cli-blueprint-test-helpers/chai')
This endpoint exports the Chai assertion library including the chai-as-promised and chai-files plugins
-
require('ember-cli-blueprint-test-helpers/helpers')
This endpoint exports the functions mentioned in the following API reference
setupTestHooks(scope, options)
Prepare the test context for the blueprint tests.
Parameters:
{Object} scope
the test context (i.e.this
){Object} [options]
optional parameters{Number} [options.timeout=20000]
the test timeout in milliseconds{Object} [options.tmpenv]
object containing info about the temporary directory for the test.{String} [options.cliPath='ember-cli']
path to theember-cli
dependency{Boolean} [options.disabledTasks=['addon-install', 'bower-install', 'npm-install']]
override the mocked installs Defaults tolib/helpers/tmp-env.js
Returns: {Promise}
emberNew(options)
Create a new Ember.js app or addon in the current working directory.
Parameters:
{Object} [options]
optional parameters{String} [options.target='app']
the type of project to create (app
,addon
orin-repo-addon
){Boolean} [options.isModuleUnification=true]
a toggle to use MU file structure
Returns: {Promise}
emberGenerate(args, options)
Run a blueprint generator.
Parameters:
{Array.<String>} args
arguments to pass toember generate
(e.g.['my-blueprint', 'foo']
){Object} [options]
optional parameters{Boolean} [options.isModuleUnification=true]
a toggle to use MU file structure
Returns: {Promise}
emberDestroy(args, options)
Run a blueprint destructor.
Parameters:
{Array.<String>} args
arguments to pass toember destroy
(e.g.['my-blueprint', 'foo']
){Object} [options]
optional parameters{Boolean} [options.isModuleUnification=true]
a toggle to use MU file structure
Returns: {Promise}
emberGenerateDestroy(args, assertionCallback, options)
Run a blueprint generator and the corresponding blueprint destructor while checking assertions in between.
Parameters:
{Array.<String>} args
arguments to pass toember generate
(e.g.['my-blueprint', 'foo']
){Function} assertionCallback
the callback function in which the assertions should happen{Object} [options]
optional parameters{Boolean} [options.isModuleUnification=true]
a toggle to use MU file structure
Returns: {Promise}
modifyPackages(packages)
Modify the dependencies in the package.json
file of the test project.
Parameters:
{Array.<Object>} packages
the list of packages that should be added, changed or removed
setupPodConfig(options)
Setup usePods
in .ember-cli
and/or podModulePrefix
in environment.js
.
Parameters:
{Object} [options]
optional parameters{Boolean} [options.usePods]
addusePods
in.ember-cli
{Boolean} [options.podModulePrefix]
setnpodModulePrefix
toapp/pods
inconfig/environment.js
Used by
- https://github.com/emberjs/ember.js
- https://github.com/emberjs/data
- https://github.com/ember-cli/ember-cli-legacy-blueprints
- https://github.com/simplabs/ember-simple-auth
- https://github.com/DockYard/ember-suave
License
This project is licensed under the MIT License.