I am trying to write my unit tests with Jasmine and Karma in Typescript.
I installed karma, karma typescript, karma jasmine, jasmine and jasmine-ts.
I added custom tsconfig.json to the spec directory and use it in karma typescript settings.
As a rule, my tests work, however it does not execute my special assistants.
Is there something that I am missing to execute my spec helpers?
For your reference, here is my configuration:
karma.conf.js :
module.exports = function (config) { config.set({
jasmine.json (Although I have a feeling that it is not used):
{ "spec_dir": "spec", "spec_files": [ "**/*[sS]pec.ts" ], "helpers": [ "helpers/**/*.ts" ], "stopSpecOnExpectationFailure": false, "random": false, "reporters": [ { "name": "jasmine-spec-reporter#SpecReporter" } ], "project": "./spec/" }
tsconfig.json in the root:
{ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es6", "dom", "es2015.promise" ], "module": "commonjs", "target": "es5", "sourceMap": true, "outDir": "./dist/", "noImplicitAny": false, "allowJs": true, "baseUrl": "src", "typeRoots": [ "node_modules/@types", "typings" ] }, "include": [ "src/**/*" ] }
tsconfig.json in the spec folder:
{ "extends": "../tsconfig.json", "compilerOptions": { "typeRoots": [ "../node_modules/@types", "typings" ] }, "include": [ "./**/*", "../src/**/*" ] }
spec/helpers/chai.ts is a spec helper that is not executed by karma.
The contents of this file are:
import * as chai from "chai"; import chaiThings = require("chai-things"); import chaiInterface = require("chai-interface"); chai.should(); chai.use(chaiThings); chai.use(chaiInterface);
Please see https://github.com/dhilgarth/mjt for a standalone example.
source share