0

--- UPDATE ---

So I updated my task and now I have the following, the problem is that when it gets into the spec the first line is the following

import {Injector, provide} from "angular2/core";

Unfortunately this is not referencing the node_modules/angular2 directory but rather the project root !!!

var jasmine = require('gulp-jasmine');
var System = require('systemjs');

gulp.task('newtest', () => {

System.config({
    baseURL: "/",
    transpiler: 'typescript',
    defaultJSExtensions: true,
    path: {
        "node_modules*": "node_modules/*"           
    },
    packages: {
        "app": {
            "defaultExtension": "js"
        }
    },      
    maps:{
        "angular2": "/node_modules/angular2",
    },
});

Promise.all([
    System.import('app/assets/services/config.service.spec'),
]).then(function(){     
    gulp.src(['app/assets/services/config.service.spec'])
        .pipe(jasmine())
}).catch(console.error.bind(console));

});

--- OLD ---

So I may be new to this thing, but I am trying to use gulp to build, lint and test my demo solution. The app is using Angular 2, Gulp, SystemJS, Gulp-tslint and Gulp-Jasmine, however I am unable to get the Gulp-Jasmine to run without falling over. It complains with the following:

events.js:141
throw er; // Unhandled 'error' event
^
TypeError: Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:2981:17)
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:3655:29)
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:4142:33)
at SystemJSNodeLoader.reduceRegister_ (D:\ng2demo\node_modules\systemjs\dist
\system.src.js:4142:33)
at SystemJSNodeLoader.pushRegister_ (D:\ng2demo\node_modules\systemjs\dist\system.src.js:2699:14)
at SystemJSNodeLoader.SystemJSLoader.register (D:\ng2demo\node_modules\syste
mjs\dist\system.src.js:2937:10)
at Object. (D:\ng2demo\app\assets\services\config.service.spec.js
:4:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)

The JS file it is attempting to run is a spec written in TypeScript and transpiled to JS with gulp-typescript. So the top line of the file is:

System.register(['angular2/core', 'angular2/http', 'angular2/http/testing',
./config.service'], function(exports_1, context_1) {
//Do Stuff
});

It is this line it has a problem with, any ideas?

HeavenlyHost
  • 75
  • 2
  • 11
  • 1
    In the future, just indent the code/errors with four spaces (or highlight it and use control+k/command+k). – Laurel Apr 23 '16 at 19:56

1 Answers1

0

it appears you are missing a ' in this line:

./config.service'], function(exports_1, context_1) {

should be:

System.register(['angular2/core', 'angular2/http', 'angular2/http/testing',
'./config.service'], function(exports_1, context_1) {
//Do Stuff
});
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • Thanks Jeff, that was simply a typo on my behalf :P anyway just checked the code and it does contain it. Do you have any other ideas ? some people suggest using commonJS rather than SystemJS as module loader, however the Google dev team have used SystemJS, so I would have thought that Gulp-Jasmine would handle it. I mean if I run npm test it works but gulp is having the problem. Anything I am missing ? – HeavenlyHost Apr 24 '16 at 20:13