Jasmine-reporter在angularjs端到端测试中的错误

时间:2014-06-24 11:59:07

标签: angularjs protractor jasmine-node

我正在尝试将Jasmine报告与Angular端到端测试集成。但是在运行测试时我遇到了以下错误(我甚至在基于Windows的环境中尝试过相同的结果),

in on prepare method
Error: Cannot find module 'jasmine-reporters'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at exports.config.onPrepare (/apps/opt/projects/pcp/workspace/pcp/modules/web/public/test/config/protractor-e2e-conf.js:18:6)
    at Runner.runFilenamesOrFns_ (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/lib/runner.js:64:9)
    at Runner.runTestPreparers (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/lib/runner.js:91:8)
    at runner.controlFlow.execute.then.jasmineNodeOpts (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/lib/frameworks/jasmine.js:39:12)
    at webdriver.promise.ControlFlow.runInNewFrame_ (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1531:20)
    at webdriver.promise.ControlFlow.runEventLoop_ (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1396:8)
==== async task ====
run test preparers
    at Object.exports.run (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/lib/frameworks/jasmine.js:38:24)
    at driverprovider_.setupEnv.then.then.then.testResult (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/lib/runner.js:233:28)
    at _fulfilled (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/q/q.js:759:13)
    at /apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/q/q.js:525:49
    at flush (/apps/softwares/node-v0.10.28-linux-x86/lib/node_modules/protractor/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)

我已经添加了'Jasmine-reporter'作为npm install -g jasmine-reporter

我也可以看到下面的文件夹,

/node-v0.10.28-linux-x86/lib/node_modules/jasmine-reporters

我的量角器配置如下,

exports.config = {
        seleniumAddress: 'http://172.16.136.181:4444/wd/hub',

        specs: [
                '../e2e/*.js',
              ],

        capabilities: {
            'browserName': 'chrome'
        },

        baseUrl:'http://gdc-java64-13:9000',

        allScriptsTimeout: 96000,

        onPrepare: function() {

        require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(null, true, true, 'testresults.e2e'));

        },


          jasmineNodeOpts: {
                // onComplete will be called just before the driver quits.
                onComplete: null,
                // If true, display spec names.
                isVerbose: false,
                // If true, print colors to the terminal.
                showColors: true,
                // If true, include stack traces in failures.
                includeStackTrace: true,
                // Default time to wait in ms before a test fails.
                defaultTimeoutInterval: 30000
              }

};

有人有任何想法。

谢谢

1 个答案:

答案 0 :(得分:2)

我将NODE_PATH环境变量设置为

后解决了这个问题

export NODE_PATH = /apps/softwares/node-v0.10.28-linux-x86/lib/node_modules

根据this