I am working with a testing project, where I am writing a pure Javascript Jasmine Karma setup to test a pre-compiled Typescript setup. However, I can not get the test cases to start.
I can see the console messages that come from compiled typescript within the console fire alright, but it simply will not start the test scripts.
Note this came from an AngularApp, but this entire part comes from a section was made and compiled without Angular2.
There is no error message, outside of it showing that 0/0 tests were run, and there was no timestamp for "component/to/test".
In the test.spec.js file, I have
define("testName", ["component/to/test"], function(component){
describe("testing module", function(){
it("should work", function(){expect(true).toEqual(true)});
})
}
In the compiled typescript file, myTs.js
var requirejs, require, define;
(function (global) {
define("component/to/test" ["depend", "ences"]), function(depend,ences)
{ more code here })
some compiled typescript here
});
require.config({
path: {path to javascript libs},
shim: { ... }
})
In my karma file
basePath: '',
frameworks: ['jasmine', 'requirejs'],
files: [
'lib1',
'lib2',
'spec/test-main.js',
{pattern: 'js/*.js', included: true, served: true},
{pattern: 'spec/*.spec.js', included: false, served: true}
],
exclude: [],
reporters: ['progress'],
autoWatch: true,
browsers: ['Chrome']
In my test-main.js, which I got from karma init after it asked if I wanted to use requirejs.
var allTestFiles = []
var TEST_REGEXP = /(spec|test)\.js$/i
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '')
allTestFiles.push(normalizedTestModule)
}
})
require.config({
baseUrl: 'base',
deps: allTestFiles,
callback: window.__karma__.start
})
comments and some not related code was removed for space.