I'm using jspm to manage the modules in my project.
I'd like to write tests using tape and using ES6 syntax.
I'd like to be able to run those tests from the command line using npm test
.
If I run jspm run test/example.js
directly from the command line, the test runs.
If I add
"scripts" : {
"test" : "jspm run test/example.js"
}
to package.json
and then run npm test
, the test runs.
So far so good, but I'd like to be have multiple tests in the test
dir. jspm run
only seems to support one module at a time.
If I replace jspm run
with babel-node
, I get Error: Cannot find module 'tape'
. This error makes sense to me i.e babel-node
doesn't know where tape
is, only jspm
does.
So is there a way of saying to npm test
, "run all these tests in here and if you can't find a module, ask jspm"?
Here is my sample test
import test from 'tape';
test('A passing test', (assert) => {
assert.pass('This test will pass.');
assert.end();
});
test('Assertions with tape.', (assert) => {
const expected = 'something to test';
const actual = 'sonething to test';
assert.equal(actual, expected,
'Given two mismatched values, .equal() should produce a nice bug report');
assert.end();
});
Here is my directory structure.
package.json
test
| - example.js
Here is my package.json
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "ISC",
"jspm": {
"devDependencies": {
"babel": "npm:babel-core@^5.8.24",
"babel-runtime": "npm:babel-runtime@^5.8.24",
"core-js": "npm:core-js@^1.1.4",
"tape": "npm:tape@^4.2.2"
}
},
"devDependencies": {
"jspm": "^0.16.13"
},
"scripts" : {
"test" : "jspm run test/example.js" //<-- what should I put here?
}
}