Currently, I am immersed in a testing project that involves setting up a pure Javascript Jasmine Karma environment to test a pre-compiled Typescript setup. Despite my efforts, I am facing an issue where the test cases refuse to start running.
While the console logs the messages from the compiled typescript without any problem, the actual test scripts fail to initiate.
It is important to note that this segment originated from an AngularApp but was created and compiled independently from Angular2.
Upon checking, there are no error messages displayed except for the notification that 0 out of 0 tests were executed, along with a missing timestamp for "component/to/test".
Within the test.spec.js file, the structure follows:
define("testName", ["component/to/test"], function(component){
describe("testing module", function(){
it("should work", function(){expect(true).toEqual(true)});
})
}
As for the compiled typescript file, myTs.js, it looks like this:
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: { ... }
})
Moving on to the karma file configuration:
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']
Furthermore, in the test-main.js file, obtained after running karma init and opting 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
})
For the sake of brevity, comments and unrelated code have been excluded to save space.