Create jasmine tests and run them as the following codes:
$ meteor create jasmineEx
$ cd jasmineEx
$ meteor create --package newfairscommerce:add-number
$ rm packages/add-number/add-number-tests.js
$ mkdir -p packages/add-number/tests/{server,client}
$ cat << EOF > packages/add-number/tests/example-spec.js
describe('sanjo:jasmine on client and server', function() {
it('works', function() {
expect(it).toBeDefined();
})
})
EOF
$ cat << EOF > packages/add-number/tests/client/example-spec.js
describe('sanjo:jasmine on client', function() {
it('works', function() {
expect(it).toBeDefined();
})
})
EOF
$ cat << EOF > packages/add-number/tests/server/example-spec.js
describe('sanjo:jasmine on server', function() {
it('works', function() {
expect(it).toBeDefined();
})
})
EOF
And replace Package.onTest
in packages/add-number/package.js with the following codes:
Package.onTest(function(api) {
api.use('sanjo:jasmine@0.18.0');
api.use('velocity:html-reporter@0.9.0');
api.use('velocity:console-reporter@0.1.3');
api.addFiles('tests/server/example-spec.js', 'server');
api.addFiles('tests/client/example-spec.js', 'client');
api.addFiles('tests/example-spec.js', ['server', 'client']);
});
Now run VELOCITY_TEST_PACKAGES=1 meteor test-packages --driver-package velocity:html-reporter newfairscommerce:add-number
under the root directory of jasmineEx project,
you can get the following output:
...
=> App running at: http://localhost:3000/
I20151003-18:23:56.465(8)? jasmine-server-integration: 2 tests passed (11ms)
I20151003-18:24:07.849(8)? jasmine-client-integration: 2 tests passed (3ms)
And you can get the test results in browser with url "http://localhost:3000".
Questions:
When running the following codes, it runs into a interactive shell:
npm install -g velocity-cli
velocity test-package newfairscommerce:add-number