2017-07-10 58 views
0

我似乎无法使用量角器运行我的e2e测试。在我开始这里是一些背景资料:无法使用量角器运行e2e测试:无法解析路径?

Node: 7.7.4 
NPM: 4.1.2. 
Angular: 4.1.0 
Protractor: 5.1.2 

我跑npm install protractor后,我安装和更新网络驱动程序并得到了IE浏览器的更新。在我写了第一个测试之后 - 一个简单的测试,在我的登录页面上抓取h1标签的文本 - 我尝试运行量角器并得到一个错误:Error: Cannot find module ‘ts-node’因此我去安装它。现在,当我重新运行量角器时,出现一个我无法解决的神秘错误:the specified path does not exist: e2e/tsconfig.e2e.json。这是什么意思?我量角器conf.js文件看起来像这样:

// Protractor configuration file, see link for more information 
// https://github.com/angular/protractor/blob/master/lib/config.ts 

const { SpecReporter } = require('jasmine-spec-reporter'); 

exports.config = { 
    allScriptsTimeout: 11000, 
    specs: [ //path of specs is relative to location of protractor.conf.js file. 
    './e2e/**/*.e2e-spec.ts' 
    ], 
    capabilities: { 
     //'browserName': 'chrome' ---default 
     'browserName': 'internet explorer', 
     'platform': 'ANY', 
     'version': '11' 
    }, 
    directConnect: true, 
    baseUrl: 'http://localhost:4200/', 
    framework: 'jasmine', 
    // Options to be passed to Jasmine-node. 
    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 30000, 
    print: function() {} 
    }, 
    beforeLaunch: function() { 
    require('ts-node').register({ 
     project: 'e2e/tsconfig.e2e.json' 
    }); 
    }, 
    onPrepare() { 
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 
    } 
}; 

我试着打打闹闹与项目参数下的路径,但没有运气解决这个问题。而我的项目结构设置喜欢这样的:

proj structure

有什么建议?我应该在github上发布这个问题吗?为ts节点?或量角器?任何建议,将不胜感激。请让我知道你是否还需要额外的环境。

回答

1

这意味着它试图找到tsconfig.e2e.json(您的'e2e'项目的typescript配置文件),不能。在配置这部分显示了它寻找的路径:

beforeLaunch: function() { 
    require('ts-node').register({ 
     project: 'e2e/tsconfig.e2e.json' 
    }); 
    }, 

但它是从你的目录结构清楚,这是不存在的。由于路径的规范文件,我可以想象该行应为:

project: './e2e/tsconfig.e2e.json' 

在项目结构看,虽然,它很可能是:

project: './app/e2e/tsconfig.e2e.json' 

在这种情况下,路径到您的spec文件可能需要更改才能匹配。

+0

谢谢!我就是这样读取错误的,并且我在路上摆弄,但没有成功。如果一切顺利,我会明天尝试并接受你的回答。 – jrDeveloper