Jasmine Spec as Typescript File


I'm attempting to set up unit testing in my project, using Jasmine. I am writing my specs in Typescript. My first test is simply checking that a config file returns a value as expected. However, when I import the config, Jasmine can't find the spec. If I take out the import and fill in dummy values, everything works fine.

My spec file is:

/// <reference path="../typings/index.d.ts"/> process.env.ENV = "test"; process.env.TEST_DB_NAME= "test"; import environment = require("../config/config"); describe("Config Tests:", () => { it("db returns string", () => { expect(environment.db).toEqual(process.env.TEST_DB_NAME); }); });

environment.db should simply return my process.env.TEST_DB_NAME.

I feel this has to do something with the import at the beginning making Jasmine not find the describe(). Anyone know of a way to get Jasmine to work with imports or am I just going about testing this the wrong way?


If you call require directly in your file I think you need to create a module and export it. Another way that I have used import successfully has been to create an interface, export it, and then did something like this.

import IUser = UserList.Interfaces.IUser;

You can then use this as the type for a mock object.


  • jaxb xsd prefix package names
  • NHibernate Lazy Loading Behaviour
  • Testing Rails module without loading ActiveRecord
  • How to call BeanFactoryPostProcessor.postProcessBeanFactory method when use Spring with XML configur
  • Angular2 & SystemJS : Cannot find module while building a moduleLoader
  • What does the TypeScript “lib” option really do?
  • text-align justify, cannot override
  • Is there any purpose for h2-h6 headings in HTML5?
  • Why does the font in these TD elements render at different sizes?
  • php script is parsing content from RTE (tt_news) but internal links are not appearing as speaking ur
  • Why must we declare a variable name when adding a method to a struct in Golang?
  • CERN ROOT exporting data to plain text
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Retrieving value from sql ExecuteScalar()
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • ILMerge & Keep Assembly Name
  • Convert array of 8 bytes to signed long in C++
  • Large data - storage and query
  • How can I estimate amount of memory left with calling System.gc()?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Why winpcap requires both .lib and .dll to run?
  • WOWZA + RTMP + HTML5 Playback?
  • Return words with double consecutive letters
  • Matrix multiplication with MKL
  • Python: how to group similar lists together in a list of lists?
  • Proper way to use connect-multiparty with express.js?
  • Hits per day in Google Big Query
  • Understanding cpu registers
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • Busy indicator not showing up in wpf window [duplicate]
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • How can i traverse a binary tree from right to left in java?
  • Conditional In-Line CSS for IE and Others?