Why should I duplicate packages that I specified in Package.onUse in Package.onTest in Meteor?

The following command appears in the next command

$ meteor test-packages --driver-package practicalmeteor:mocha rocketchat:spotify 

Console exit

 => Errors prevented startup: While building package local-test:rocketchat:spotify: error: No plugin known to handle file 'spotify.test.coffee'. If you want this file to be a static asset, use addAssets instead of addFiles; eg, api.addAssets('spotify.test.coffee', 'client'). 

I am confused since I pointed out the coffeescript package in Package.onUse.

rocketchat-Spotify / package.js

 Package.describe({ name: 'rocketchat:spotify', version: '0.0.1', summary: 'Message pre-processor that will translate spotify on messages', git: '' }); Package.onUse(function(api) { api.versionsFrom('1.0'); api.use([ 'coffeescript', # Coffeescript is included here? 'templating', 'underscore', 'rocketchat: oembed@0.0.1 ', 'rocketchat:lib' ]); api.addFiles('lib/client/widget.coffee', 'client'); api.addFiles('lib/client/oembedSpotifyWidget.html', 'client'); api.addFiles('lib/spotify.coffee', ['server', 'client']); }); Package.onTest(function (api) { api.use([ 'rocketchat:spotify' ]); api.addFiles('spotify.test.coffee'); }); 

Adding the coffeescript package as follows fixes the problem

 Package.onTest(function (api) { api.use([ 'coffeescript', 'rocketchat:spotify' ]); api.addFiles('spotify.test.coffee'); }); => Modified -- restarting. => Meteor server restarted => Started your app. 

Console exit

 => App running at: http://localhost:3000/ I20160602-17:55:02.867(9)? Updating process.env.MAIL_URL I20160602-17:55:04.528(9)? MochaRunner.runServerTests: Starting server side tests with run id aXdi2H3kBS8M8Fuhx W20160602-17:55:04.577(9)? (STDERR) MochaRunner.runServerTests: failures: 10 

Version Information

 $ meteor --version Meteor 1.2.1 
+5
source share
1 answer

According to the Package.onTest documentation, you need to specify the dependencies of your tests separately. So, if CoffeeScript is used in your unit tests, you need to explicitly specify it in the onTest .

You can think of unit test packages as a standalone package built on top of a test package.

Why?

MDG did this because sometimes your tests have different dependencies, and then the package you are testing. For example: you wrote a package in CoffeeScript, but your tests are written in plain JavaScript. Then the CoffeeScript dependency is redundant for tests. And the current version of the API allows you to separately specify these dependencies.

+2
source

All Articles