Reputation: 574
I am using Jasmine to writing Unit Test for my AngularJS project, But it seem dulicate code because in each spec file I have to add some references like below
/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine.js" />
/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine-html.js" />
/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/boot.js" />
/// <reference path="../../../bower_components/jquery/dist/jquery.min.js" />
/// <reference path="../../../bower_components/jquery/dist/jquery.js" />
/// <reference path="../../../bower_components/angular/angular.js" />
/// <reference path="../../../vendors/js/jBox.js" />
/// <reference path="../../../bower_components/angular-mocks/angular-mocks.js" />
And so on
Is there a way extract the references into one external file, then I just add only that file on each test spec file.
Upvotes: 1
Views: 235
Reputation: 28757
Your best bet is to use typings to manage your third party type libraries. It works like this (copied from the typings quickstart guide):
# Install Typings CLI utility.
npm install typings --global
# Search for definitions.
typings search tape
# Find an available definition (by name).
typings search --name react
# If you use the package as a module:
# Install non-global typings (defaults to "npm" source, configurable through `defaultSource` in `.typingsrc`).
typings install debug --save
# If you use the package through script tag, or
# it is part of the environment, or
# the non-global typings is not yet available:
typings install dt~mocha --global --save
# Install typings from particular registry.
typings install env~atom --global --save
typings install npm~bluebird --save
# Use `typings/index.d.ts` (in `tsconfig.json` or as a `///` reference).
cat typings/index.d.ts
Then, once you have done this, either in every file you put a ///
reference to typings/index.d.ts
in every test file. Or (this is better) put a reference to typings/index.d.ts
in your tsconfig file like this:
{
"files": [
"typings/index.d.ts"
]
}
Upvotes: 1