遇到Phantomjs启动程序致命Windows异常

时间:2017-01-28 09:49:48

标签: phantomjs karma-runner gulp-karma

我在通过gulp运行业力测试时遇到问题。

我正在使用phantomjs启动程序插件,当它尝试启动时,我会看到以下内容:

[09:27:02] Starting 'karma-tests'...
DEPRECATED: use your own version of lodash, this will go away in karma@2.0
DEPRECATED: use your own version of lodash, this will go away in karma@2.0
28 01 2017 09:27:04.817:INFO [karma]: Karma v1.4.0 server started at http://0.0.0.0:9876/
28 01 2017 09:27:04.817:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
28 01 2017 09:27:04.817:INFO [launcher]: Starting browser PhantomJS
28 01 2017 09:27:07.882:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket VwHY_WyYXMEj3RvZAAAA with id 284
68634
28 01 2017 09:27:08.436:ERROR [phantomjs.launcher]: Fatal Windows exception, code 0xc0000005.
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.

28 01 2017 09:27:08.471:ERROR [launcher]: PhantomJS crashed.

28 01 2017 09:27:08.475:INFO [launcher]: Trying to start PhantomJS again (1/2).
28 01 2017 09:27:10.457:WARN [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Disconnected (1 times)
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
  Disconnectedundefined

[09:27:10] 'karma-tests' errored after 7.9 s
[09:27:10] Error: 1
    at formatError (C:\Users\asus\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:169:10)
    at Gulp.<anonymous> (C:\Users\asus\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:195:15)
    at emitOne (events.js:101:20)
    at Gulp.emit (events.js:188:7)
    at Gulp.Orchestrator._emitTaskDone (C:\Users\asus\Documents\Github\interACT\node_modules\orchestrator\index.js:264
:8)
    at C:\Users\asus\Documents\Github\interACT\node_modules\orchestrator\index.js:275:23
    at finish (C:\Users\asus\Documents\Github\interACT\node_modules\orchestrator\lib\runTask.js:21:8)
    at cb (C:\Users\asus\Documents\Github\interACT\node_modules\orchestrator\lib\runTask.js:29:3)
    at removeAllListeners (C:\Users\asus\Documents\Github\interACT\node_modules\karma\lib\server.js:380:7)
    at Server.<anonymous> (C:\Users\asus\Documents\Github\interACT\node_modules\karma\lib\server.js:391:9)
    at Server.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at Server.emit (events.js:185:7)
    at emitCloseNT (net.js:1555:8)
    at _combinedTickCallback (internal/process/next_tick.js:71:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

我正在使用最新版本的karma和phantomjs启动器,我的package.json中有以下条目:

"karma": "^1.4.0",
"karma-phantomjs-launcher": "^1.0.2"

另外我全球安装了Phantomjs 2.1.1

错误的性质似乎暗示这与Windows有关,我在Windows 10 64位平台上运行。

我正在运行的项目实际安装在其他一些混合了Windows 7,Windows 10和Linux的机器上。我在其他10台机器上看到了这个问题,其余的平台看起来很好。直到最近(过去几周大约)我还没有在win 10上看到这个问题,所以我想知道某种Windows更新是否会导致无法预料的副作用。

我偶然更改了我的karma配置文件中的端口号并且它设法运行测试,但是在进一步运行时它再次失败并出现相同的错误。再次更改端口没有任何区别。

我的业力配置如下:

module.exports = function(config) {
  config.set({
    logLevel : config.LOG_INFO,
    colors: true,
    browsers: ['PhantomJS'],
    singleRun: true,
    port: 9876,
    autoWatch: false,
    basePath: '../',
    reporters: ['progress', 'coverage'],

    coverageReporter: {
      dir : 'test/coverage/',
      reporters: [{
        type: 'lcovonly',
        subdir: '.',
        file: 'karma-coverage.dat'
      }, {
        type : 'json',
        subdir: '.',
        file : 'karma-results.json'
      }]
    },

    frameworks: ['jasmine'],
    exclude: ['../dist/client/assets/scripts/angular_app.js'],
    files: [
      'dist/client/assets/scripts/jquery.js',
      'dist/client/assets/scripts/bootstrap.js',
      'dist/client/assets/scripts/bower_libs.js',
      'dist/client/assets/scripts/d3.min.js',
      'dist/client/assets/scripts/main.js',
      'test/mocks/mocks.config.js',
      'test/mocks/**/*.mock.js',
      'src/client/app/**/*.module.js',
      'src/client/app/**/!(*spec).js',
      'src/client/app/**/*.spec.js'
    ],

    preprocessors: {
      'src/client/app/**/!(*spec).js': ['coverage']
    }
  });
};

有没有人遇到过此问题,如果有,您是否设法找到解决方案?

如果您需要更多详细信息,请与我们联系。

由于

1 个答案:

答案 0 :(得分:5)

我最终通过使用2.5.0 beta找到了一个解决方案,可以从here获取并替换phantomjs构建模块附带的幻像库文件夹中的exe。

所以对我来说,我必须坚持到这里:

PROJECT_ROOT\node_modules\phantomjs-prebuilt\lib\phantom\bin

这已经成功了,不再是致命的例外!虽然看起来不会很快发布2.5,但https://github.com/ariya/phantomjs/milestones

自担风险使用!