2016-04-13 13 views
1

Ich baue eine neue Angular 2 App mit dem Alpha Angular-CLI aus. Ich benutze auch die ng2-material Bibliothek. Um es sogar an die Arbeit hatte ich folgendes zu tun: sichAngular CLI - Karma Test Build nicht gefunden ng2-Material

// index.html 
System.config({ 
    packages: { 
     app: { 
      format: 'register', 
      defaultExtension: 'js 
     }, 
     'ng2-material': { 
      format: 'cjs', 
      defaultExtension: 'js', 
      main: 'all.js' 
     } 
    } 
    }); 
    System.import('app.js').then(null, console.error.bind(console)); 

// ember-cli-build.js 
var materialTree = BroccoliFunnel('node_modules/ng2-material', { 
    destDir: 'ng2-material' 
}); 

Es funktioniert gut in der App. Allerdings, wenn ich ng test laufen bekomme ich folgende Fehlermeldung:

START:

13 04 2016 14:55:36.982:WARN [web-server]: 404: /ng2-material/all

Chrome 49.0.2623 (Mac OS X 10.11.3) ERROR

Error: XHR error (404 Not Found) loading http://localhost:9876/ng2-material/all

at error (/../node_modules/systemjs/dist/system.src.js:1026:16) 

at XMLHttpRequest.xhr.onreadystatechange (/../node_modules/systemjs/dist/system.src.js:1047:13) 

13 04 2016 14:55:37.058:WARN [web-server]: 404: /ng2-material/all

Was bin ich?

Antwort

0

In Ihrem karma-test-shim.js versuchen, das Modul geladen, bevor die Tests Laden:

System.import('system-config.js').then(function() { 
    // Load and configure the TestComponentBuilder. 
    return Promise.all([ 
    System.import('@angular/core/testing'), 
    System.import('@angular/platform-browser-dynamic/testing') 
    ]).then(function (providers) { 
    var testing = providers[0]; 
    var testingBrowser = providers[1]; 

    testing.TestBed.initTestEnvironment(testingBrowser.BrowserDynamicTestingModule, 
     testingBrowser.platformBrowserDynamicTesting()); 
    }); 
///////////////// Add this part ///////////////// 
}).then(function() { 
    return System.import('/path/to/ng2-material.js/in/node_modules'); 
///////////////////////////////////////////////// 
}).then(function() { 
    // Finally, load all spec files. 
    // This will run the tests directly. 
    return Promise.all(
    allSpecFiles.map(function (moduleName) { 
     return System.import(moduleName); 
    })); 
}).then(__karma__.start, __karma__.error); 
Verwandte Themen