Skip to content

Uncaught SyntaxError: Unexpected token import #45

@sudhamsa

Description

@sudhamsa

Here is my angular module,

app.ts:

 /// <reference path='../thirdparty/jasmine/jasmine.d.ts'/>
 /// <reference path= '../thirdparty/angular/angular.d.ts'/>
 import {common} from './modules/common/Common.module';
 var app:ng.Imodule= angular.module('comp', [common.name]);

app.test.ts:

    /// <reference path='../thirdparty/jasmine/jasmine.d.ts'/>
   /// <reference path= '../thirdparty/angular/angular.d.ts'/>

   import {comp} from './app';

   export function main() {
     describe('comp', function () {
    it('Comp should be defined', function () {
        expect(comp).toBeDefined();
    });
    });
   }

Karma.config.ts

   module.exports = function (config) {
    config.set({
    frameworks: ['jasmine'],
    basePath: '',
    preprocessors: {
        'app/app.ts': ['typescript'],
        'app/app.test.ts': ['typescript']
    },
    typescriptPreprocessor: {
        typings: [
            'thirdparty/jasmine/jasmine.d.ts',
            'node_modules/typescript/typescript.d.ts',
            'thirdparty/angular/angular.d.ts',
            'thirdparty/jquery/src/jquery.d.ts'
        ],
        options: {
            sourceMap: false,
            target: 'ES5',
            module: 'commonjs',
            noImplicitAny: true,
            noResolve: true,
            removeComments: true,
            concatinateOutput: false
        },
    },
    files: [
        'app/modules/**/*.module.ts',
        'app/app.ts',
        'app/app.test.ts',
        'node_modules/requirejs/require.js'
    ],
    exclude: [
        'modules/**/e2e_test/**',
        'app/**/e2e/**/*.js',
        'thirdparty/pioneer/featureFlag/**/*{t,T}est.js',
        'app/Templates.ts',
        'app/routes.ts',
        'app/ThirdpartyTemplates.ts'
    ],
    browsers: ['Chrome'],
    reporters: ['spec', 'junit'],
    specReporter: { maxLogLines: 5 },
    junitReporter: {
        outputFile: './build/work/jasmine/TEST-results.xml',
        suite: 'COMP'
    },
    port: 9876
});
 };

running the test throws error saying that unexpected token import and cannot import app. Not sure whats is wrong. Did some one came across this issue? Can some point where is the mistake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions