2016-09-29 79 views
1

我正在嘗試使用Karma設置自動測試。雖然我遇到了問題。Karma - 使用PhantomJS代替Chrome

NPM啓動或安裝NPM給我這個錯誤:

> concurrently "npm run tsc:w" "npm run lite" 

[0] /c: /c: is a directory 
[1] /c: /c: is a directory 
[0] npm run tsc:w exited with code 126 
[1] npm run lite exited with code 126 

npm ERR! Windows_NT 10.0.10586 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Ivar\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start" 
npm ERR! node v4.5.0 
npm ERR! npm v3.10.8 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `concurrently "npm run tsc:w" "npm run lite" ` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'concurrently "npm run tsc:w" "npm run lite" '. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the angular-quickstart package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  concurrently "npm run tsc:w" "npm run lite" 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs angular-quickstart 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls angular-quickstart 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 

之前,他們給了我:

> karma start karma.conf.js 

29 09 2016 16:49:27.659:WARN [watcher]: Pattern "C:/Users/Ivar/documents/school/stage/workspace/webapplicatie/systemjs.config.extras.js" does not match any file. 
29 09 2016 16:49:27.679:WARN [watcher]: Pattern "C:/Users/Ivar/documents/school/stage/workspace/webapplicatie/app/**/*.css" does not match any file. 
29 09 2016 16:49:27.691:WARN [watcher]: Pattern "C:/Users/Ivar/documents/school/stage/workspace/webapplicatie/test/**/*.ts" does not match any file. 
29 09 2016 16:49:27.692:WARN [watcher]: Pattern "C:/Users/Ivar/documents/school/stage/workspace/webapplicatie/test/**/*.js.map" does not match any file. 
29 09 2016 16:49:28.158:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/ 
29 09 2016 16:49:28.159:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency 
29 09 2016 16:49:28.166:INFO [launcher]: Starting browser PhantomJS 
29 09 2016 16:49:29.956:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#GGY-X69uV6wlYJOnAAAA with id 60252055 
29 09 2016 16:49:30.387:WARN [web-server]: 404: /base/node_modules/systemjs/dist/system-polyfills.js 
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR 
    TypeError: undefined is not a constructor (evaluating 'System.config') 
    at karma-test-shim.js:30 

PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR 
    TypeError: undefined is not a constructor (evaluating 'System.config') 
    at karma-test-shim.js:30 

npm ERR! Test failed. See above for more details. 

而在node_modules/systemjs/DIST的系統正-polyfills.js確實存在。

現在我的人緣配置代碼:

module.exports = function(config) { 

    var appBase = 'app/';  // transpiled app JS and map files 
    var appSrcBase = 'app/';  // app source TS files 
    var appAssets = '/base/app/'; // component assets fetched by Angular's compiler 

    var testBase = 'test/';  // transpiled test JS and map files 
    var testSrcBase = 'test/';  // test source TS files 

    config.set({ 
    basePath: '', 
    frameworks: ['jasmine'], 
    plugins: [ 
     require('karma-jasmine'), 
     require('karma-phantomjs-launcher'), 
     require('karma-jasmine-html-reporter'), // click "Debug" in browser to see it 
     require('karma-htmlfile-reporter') // crashing w/ strange socket error 
    ], 

    customLaunchers: { 
     // From the CLI. Not used here but interesting 
     // chrome setup for travis CI using chromium 
     Chrome_travis_ci: { 
     base: 'Chrome', 
     flags: ['--no-sandbox'] 
     } 
    }, 
    files: [ 
     // System.js for module loading 
     'node_modules/systemjs/dist/system.src.js', 

     // Polyfills 
     'node_modules/core-js/client/shim.js', 
     'node_modules/reflect-metadata/Reflect.js', 

     // zone.js 
     'node_modules/zone.js/dist/zone.js', 
     'node_modules/zone.js/dist/long-stack-trace-zone.js', 
     'node_modules/zone.js/dist/proxy.js', 
     'node_modules/zone.js/dist/sync-test.js', 
     'node_modules/zone.js/dist/jasmine-patch.js', 
     'node_modules/zone.js/dist/async-test.js', 
     'node_modules/zone.js/dist/fake-async-test.js', 

     // RxJs 
     { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, 
     { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, 

     // Paths loaded via module imports: 
     // Angular itself 
     {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, 
     {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, 

     {pattern: 'systemjs.config.js', included: false, watched: false}, 
     {pattern: 'systemjs.config.extras.js', included: false, watched: false}, 
     'karma-test-shim.js', 

     // transpiled application & spec code paths loaded via module imports 
     {pattern: appBase + '**/*.js', included: false, watched: true}, 
     {pattern: testBase + '**/*.js', included: false, watched: true}, 


     // Asset (HTML & CSS) paths loaded via Angular's component compiler 
     // (these paths need to be rewritten, see proxies section) 
     {pattern: appBase + '**/*.html', included: false, watched: true}, 
     {pattern: appBase + '**/*.css', included: false, watched: true}, 

     // Paths for debugging with source maps in dev tools 
     {pattern: appSrcBase + '**/*.ts', included: false, watched: false}, 
     {pattern: appBase + '**/*.js.map', included: false, watched: false}, 
     {pattern: testSrcBase + '**/*.ts', included: false, watched: false}, 
     {pattern: testBase + '**/*.js.map', included: false, watched: false} 
    ], 

    // Proxied base paths for loading assets 
    proxies: { 
     // required for component assets fetched by Angular's compiler 
     "/app/": appAssets 
    }, 

    exclude: [], 
    preprocessors: {}, 
    // disabled HtmlReporter; suddenly crashing w/ strange socket error 
    reporters: ['progress', 'kjhtml'],//'html'], 

    // HtmlReporter configuration 
    htmlReporter: { 
     // Open this file to see results in browser 
     outputFile: '_test-output/tests.html', 

     // Optional 
     pageTitle: 'Unit Tests', 
     subPageTitle: __dirname 
    }, 

    port: 9876, 
    colors: true, 
    logLevel: config.LOG_INFO, 
    autoWatch: true, 
    browsers: ['PhantomJS'], 
    singleRun: false 
    }) 
} 

噶墊片

// #docregion 
// /*global jasmine, __karma__, window*/ 
Error.stackTraceLimit = 0; // "No stacktrace"" is usually best for app testing. 

// Uncomment to get full stacktrace output. Sometimes helpful, usually not. 
// Error.stackTraceLimit = Infinity; // 

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; 

var builtPath = '/base/app/'; 

__karma__.loaded = function() { }; 

function isJsFile(path) { 
    return path.slice(-3) == '.js'; 
} 

function isSpecFile(path) { 
    return /\.spec\.(.*\.)?js$/.test(path); 
} 

function isBuiltFile(path) { 
    return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); 
} 

var allSpecFiles = Object.keys(window.__karma__.files) 
    .filter(isSpecFile) 
    .filter(isBuiltFile); 

System.config({ 
    baseURL: '/base', 
    // Extend usual application package list with test folder 
    packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } }, 

    // Assume npm: is set in `paths` in systemjs.config 
    // Map the angular testing umd bundles 
    map: { 
    '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', 
    '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', 
    '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', 
    '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', 
    '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', 
    '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', 
    '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', 
    '@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js', 
    }, 
}); 

System.import('systemjs.config.js') 
    .then(importSystemJsExtras) 
    .then(initTestBed) 
    .then(initTesting); 

/** Optional SystemJS configuration extras. Keep going w/o it */ 
function importSystemJsExtras(){ 
    return System.import('systemjs.config.extras.js') 
    .catch(function(reason) { 
    console.log(
     'Warning: System.import could not load the optional "systemjs.config.extras.js". Did you omit it by accident? Continuing without it.' 
    ); 
    console.log(reason); 
    }); 
} 

function initTestBed(){ 
    return Promise.all([ 
    System.import('@angular/core/testing'), 
    System.import('@angular/platform-browser-dynamic/testing') 
    ]) 

    .then(function (providers) { 
    var coreTesting = providers[0]; 
    var browserTesting = providers[1]; 

    coreTesting.TestBed.initTestEnvironment(
     browserTesting.BrowserDynamicTestingModule, 
     browserTesting.platformBrowserDynamicTesting()); 
    }) 
} 

// Import all spec files and start karma 
function initTesting() { 
    console.log("init testing"); 
    return Promise.all(
    allSpecFiles.map(function (moduleName) { 

     console.log("module: "+moduleName); 
     return System.import(moduleName); 
    }) 
) 
    .then(__karma__.start, __karma__.error); 
} 

最後但並非最不重要 的package.json

{ 
    "name": "angular-quickstart", 
    "version": "1.0.0", 
    "description": "QuickStart package.json from the documentation, supplemented with testing support", 
    "scripts": { 
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", 
    "docker-build": "docker build -t ng2-quickstart .", 
    "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart", 
    "pree2e": "npm run webdriver:update", 
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first", 
    "lint": "tslint ./app/**/*.ts -t verbose", 
    "lite": "lite-server", 
    "postinstall": "typings install", 
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", 
    "test-once": "tsc && karma start karma.conf.js --single-run", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "typings": "typings", 
    "webdriver:update": "webdriver-manager update" 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "@angular/common": "~2.0.1", 
    "@angular/compiler": "~2.0.1", 
    "@angular/core": "~2.0.1", 
    "@angular/forms": "~2.0.1", 
    "@angular/http": "~2.0.1", 
    "@angular/platform-browser": "~2.0.1", 
    "@angular/platform-browser-dynamic": "~2.0.1", 
    "@angular/router": "~3.0.1", 
    "@angular/upgrade": "~2.0.1", 

    "core-js": "^2.4.1", 
    "reflect-metadata": "^0.1.8", 
    "rxjs": "5.0.0-beta.12", 
    "systemjs": "0.19.39", 
    "zone.js": "^0.6.25", 
    "angular2-in-memory-web-api": "0.0.20", 
    "bootstrap": "^3.3.7" 
    }, 
    "devDependencies": { 
    "concurrently": "^3.0.0", 
    "lite-server":"~2.2.2", 
    "canonical-path": "0.0.2", 
    "http-server": "^0.9.0", 
    "tslint": "^3.15.1", 
    "lodash": "^4.16.2", 
    "jasmine-core": "~2.5.2", 
    "karma": "^1.3.0", 
    "karma-phantomjs-launcher": "^1.0.0", 
    "karma-cli": "^1.0.1", 
    "karma-htmlfile-reporter": "^0.3.4", 
    "karma-jasmine": "^1.0.2", 
    "karma-spec-reporter": "0.0.13", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "protractor": "^3.3.0", 
    "rimraf": "^2.5.4", 
    "phantomjs-prebuilt": "^2.1.7", 
    "typescript": "^2.0.3", 
    "typings": "^1.4.0" 
    } 
} 

對不起,我的代碼量,但我可以我自己似乎找不到這個問題。

編輯:它工作本地,服務器上的我得到這個錯誤:

[email protected] test-once /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1 
build 03-Oct-2016 09:03:17 > tsc && karma start karma.conf.js --single-run 
build 03-Oct-2016 09:03:17  
build 03-Oct-2016 09:03:37 [33m03 10 2016 09:03:37.209:WARN [watcher]: [39mPattern "/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/systemjs.config.extras.js" does not match any file. 
build 03-Oct-2016 09:03:37 [33m03 10 2016 09:03:37.229:WARN [watcher]: [39mPattern "/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/app/**/*.css" does not match any file. 
build 03-Oct-2016 09:03:37 [33m03 10 2016 09:03:37.241:WARN [watcher]: [39mPattern "/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/test/**/*.ts" does not match any file. 
build 03-Oct-2016 09:03:37 [33m03 10 2016 09:03:37.242:WARN [watcher]: [39mPattern "/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/test/**/*.js.map" does not match any file. 
build 03-Oct-2016 09:03:40 [32m03 10 2016 09:03:40.938:INFO [karma]: [39mKarma v1.3.0 server started at http://localhost:9876/ 
build 03-Oct-2016 09:03:40 [32m03 10 2016 09:03:40.939:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency 
build 03-Oct-2016 09:03:40 [32m03 10 2016 09:03:40.973:INFO [launcher]: [39mStarting browser PhantomJS 
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.068:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libz.so.1: no version information available (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.069:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.081:ERROR [launcher]: [39mCannot start PhantomJS 
build 03-Oct-2016 09:03:41   
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.086:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.10' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.7' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [32m03 10 2016 09:03:41.090:INFO [launcher]: [39mTrying to start PhantomJS again (1/2). 
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.103:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libz.so.1: no version information available (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.10' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.7' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.104:ERROR [launcher]: [39mCannot start PhantomJS 
build 03-Oct-2016 09:03:41   
build 03-Oct-2016 09:03:41 [32m03 10 2016 09:03:41.106:INFO [launcher]: [39mTrying to start PhantomJS again (2/2). 
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.112:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libz.so.1: no version information available (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.112:ERROR [launcher]: [39mCannot start PhantomJS 
build 03-Oct-2016 09:03:41   
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.113:ERROR [phantomjs.launcher]: [39m/opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.9' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.10' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41 /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: /lib/libc.so.6: version `GLIBC_2.7' not found (required by /opt/bamboo-agent-home/xml-data/build-dir/MCAE-MA-JOB1/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs) 
build 03-Oct-2016 09:03:41  
build 03-Oct-2016 09:03:41 [31m03 10 2016 09:03:41.114:ERROR [launcher]: [39mPhantomJS failed 2 times (cannot start). Giving up. 
error 03-Oct-2016 09:03:41  
error 03-Oct-2016 09:03:41 npm ERR! Linux 2.6.18-92.1.22.el5 
error 03-Oct-2016 09:03:41 npm ERR! argv "/opt/node-v0.12.7-linux-x86/bin/node" "/opt/node-v0.12.7-linux-x86/bin/npm" "run" "test-once" 
error 03-Oct-2016 09:03:41 npm ERR! node v0.12.7 
error 03-Oct-2016 09:03:41 npm ERR! npm v3.10.8 
error 03-Oct-2016 09:03:41 npm ERR! code ELIFECYCLE 
error 03-Oct-2016 09:03:41 npm ERR! [email protected] test-once: `tsc && karma start karma.conf.js --single-run` 
error 03-Oct-2016 09:03:41 npm ERR! Exit status 1 
error 03-Oct-2016 09:03:41 npm ERR! 
error 03-Oct-2016 09:03:41 npm ERR! Failed at the [email protected] test-once script 'tsc && karma start karma.conf.js --single-run'. 
error 03-Oct-2016 09:03:41 npm ERR! Make sure you have the latest version of node.js and npm installed. 
error 03-Oct-2016 09:03:41 npm ERR! If you do, this is most likely a problem with the angular-quickstart package, 
error 03-Oct-2016 09:03:41 npm ERR! not with npm itself. 
error 03-Oct-2016 09:03:41 npm ERR! Tell the author that this fails on your system: 
error 03-Oct-2016 09:03:41 npm ERR!  tsc && karma start karma.conf.js --single-run 
error 03-Oct-2016 09:03:41 npm ERR! You can get information on how to open an issue for this project with: 
error 03-Oct-2016 09:03:41 npm ERR!  npm bugs angular-quickstart 
error 03-Oct-2016 09:03:41 npm ERR! Or if that isn't available, you can get their info via: 
error 03-Oct-2016 09:03:41 npm ERR!  npm owner ls angular-quickstart 
error 03-Oct-2016 09:03:41 npm ERR! There is likely additional logging output above. 

回答

2

你的Karma錯誤源於它上面的404。 Karma不提供system-polyfills.js文件。您需要將其添加到文件部分system.src.js以上的文件部分或更可能是system-polyfills.src.js。如果您還沒有創建systemjs.config.extras.js,那麼在此之後您將獲得另一個不太嚴重的錯誤。如果你沒有一個只是用這個名字創建一個空文件。

如果npm startnpm test仍然失敗後,請更新您的問題與輸出從npm install,我會更新這個答案。

+0

更新了答案,它在我的本地機器上工作,但是當我將它部署到我的服務器(c.i.)時,出現答案中顯示的錯誤。 – Ivaro18

+0

PhantomJS未在您的服務器上運行,因爲您缺少它需要的庫。 '/ lib/libz.so.1','/ usr/lib/libstdC++。so.6'和'/ usr/lib/libc.so.6'。您需要安裝它們,也可能需要安裝它們。快速谷歌搜索錯誤使我認爲您的發行版/版本可能不支持phantomjs。 https://github.com/ariya/phantomjs/issues/13940。您的glibc版本看起來太舊或不兼容。 – majinnaibu

0

問題可能從中不建議同時使用噶和量角器的不兼容系統中源:

https://github.com/angular/protractor/issues/9#issuecomment-19927049

Protractor and Karma should not be used together; instead they provide separate systems for running tests. Protractor and Karma cover different aspects of testing - Karma is intended mostly for unit tests, while Protractor should be used for end to end testing.

Protractor is built on top of WebDriverJS, which uses a Selenium/WebDriver server to provision browsers and drive test execution. Examples of pure WebDriverJS can be found here: http://code.google.com/p/selenium/wiki/WebDriverJs

https://github.com/angular/protractor/issues/9#issuecomment-19931154

Georgios - I think it makes sense to keep Protractor and Karma separate - for end to end tests, you want the native event driving and flexibility of webdriver, while for unit tests you want fast execution and autowatching of files.

原來的答覆在這裏找到: Can Protractor and Karma be used together?