2016-03-16 46 views
0

我想在量角器中生成報告,我跟着this教程來做到這一點。找不到量角器結果文件夾'量角器-html-截圖記者'

這是我的conf.js文件。

var HtmlReporter = require('protractor-html-screenshot-reporter'); 
var reporter = new HtmlReporter({ 
    baseDirectory: 'D:/My Work/Protractor/Financial/protractor-result', // a location to store screen shots.  
    docTitle: 'Protractor Demo Reporter', 
    docName: 'protractor-demo-tests-report.html' 
}); 

exports.config = { 
    framework: 'jasmine', 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['invoice.js'], 
    capabilities: { 
    browserName: 'chrome', 
    }, 
    jasmineNodeOpts: { 
    showColors: true, // Use colors in the command line report. 
    }, 
    onPrepare: function() { 
     jasmine.getEnv().addReporter(reporter); 
    } 
} 

我試圖運行這個命令使用protractor conf.js而且也沒有生成包含測試結果的文件夾。如果我使用命令,protractor specs\configurations.js會發生以下錯誤。

ERROR - failed loading configuration file specs/conf.js 
C:\Users\Manuli\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js: 
204 
    throw e; 
    ^

Error: Cannot find module 'D:\My Work\Protractor\Financial\specs\conf.js' 
    at Function.Module._resolveFilename (module.js:339:15) 
    at Function.Module._load (module.js:290:25) 
    at Module.require (module.js:367:17) 
    at require (internal/module.js:16:19) 
    at ConfigParser.addFileConfig (C:\Users\Manuli\AppData\Roaming\npm\node_modu 
les\protractor\lib\configParser.js:195:22) 
    at Object.init (C:\Users\Manuli\AppData\Roaming\npm\node_modules\protractor\ 
lib\launcher.js:103:18) 
    at Object.<anonymous> (C:\Users\Manuli\AppData\Roaming\npm\node_modules\prot 
ractor\lib\cli.js:140:23) 
    at Module._compile (module.js:413:34) 
    at Object.Module._extensions..js (module.js:422:10) 
    at Module.load (module.js:357:32) 

爲什麼我無法生成報告?

在此先感謝。 :)

+1

你在哪裏使用'茉莉記者'?你正在使用'protractor-html-screenshot-reporter',它與過時的茉莉花1.x版本一起使用。你爲什麼不嘗試更新你的東西,並使用與'jasmine2'兼容的其他記者。 –

+0

對不起。我更新了問題標題。你能建議與茉莉花兼容的物品嗎? :) –

+2

這裏是一個 - https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter –

回答

0

我改變了我的conf.js這個。

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); 

var reporter = new HtmlScreenshotReporter({ 
    dest: 'D:/My Work/Protractor/Financial/screenshots', 
    filename: 'my-report.html' 
}); 

exports.config = { 
framework: 'jasmine', 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['invoice.js'], 
    capabilities: { 
    browserName: 'chrome', 
    }, 
// Setup the report before any tests start 
    beforeLaunch: function() { 
     return new Promise(function(resolve){ 
     reporter.beforeLaunch(resolve); 
     }); 
    }, 

    // Assign the test reporter to each running instance 
    onPrepare: function() { 
     jasmine.getEnv().addReporter(reporter); 
    }, 

    // Close the report after all tests finish 
    afterLaunch: function(exitCode) { 
     return new Promise(function(resolve){ 
     reporter.afterLaunch(resolve.bind(this, exitCode)); 
     }); 
    } 
} 

然後我用npm install protractor-jasmine2-screenshot-reporter --save-dev命令來安裝NPM。

現在就工作。 :)