This project automates the setup of tests for JSPM-powered projects using Testem.
It supports the following test frameworks:
The tests run in the browser and many browsers are supported with Testem launchers: https://github.com/testem/testem#launchers
jspm-testem is both a JSPM-compatible JS module and a cli command. The cli command automates the setup of the tests and the JS module integrates Testem, JSPM and test frameworks during the runtime.
To install the CLI tool:
npm install jspm-testem -g
Assume that jspm-project-dir
is the root folder of your JSPM module. Run the following command to add Mocha(default) tests for the project
cd jspm-project-dir
jspm-testem
This will create all files required for Testem and install required JSPM dependencies. If you want to use a framework other than mocha:
jspm-testem --framework=qunit
By default the command does not override existing files. If you want to run the command again and update the test files, run:
jspm-testem --framework=qunit --force=true
The test project here https://github.com/OrKoN/simple-jspm-project has tests enabled by jspm-testem
in the master
branch. The without_tests
branch contains the version of the project before the tests were added: https://github.com/OrKoN/simple-jspm-project/tree/without_tests
Steps to add tests:
Getting the test project
git clone [email protected]:OrKoN/simple-jspm-project.git
cd simple-jspm-project
git checkout without_tests
jspm install
Adding tests
npm install testem phantomjs -g
to install Testem & Phantomjsjspm-testem
to add tests
Running tests
testem ci
You should see something like this:
testem ci
ok 1 PhantomJS 1.9 - it should work
1..1
# tests 1
# pass 1
# fail 0
# ok
jspm-testem
adds one dummy test for you (test/basic.js
) in order to test if everything works.
You can also run tests in development mode:
testem
The project is in very early stages. The API and functionality may change. If you think that some configuration options are missing or if you have troubles adapting jspm-testem
for your project, please let me know via Issues or Pull Requests on Github.