简体   繁体   English

angularjs e2e测试,没有结果

[英]angularjs e2e test, no result

When I ran SpecRunning, the web page showed nothing, but there wasn't any error. 当我运行SpecRunning时,网页没有显示任何内容,但是没有任何错误。 This is my SpecRunning.html 这是我的SpecRunning.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v<%= jasmineVersion %></title>

<link rel="shortcut icon" type="image/png" href="test/images/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="test/lib/jasmine-core/jasmine.css">

<script type="text/javascript" src="test/lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript" src="test/lib/jasmine-core/jasmine-html.js"></script>
<script type="text/javascript" src="test/lib/jasmine-core/boot.js"></script>
<script type="text/javascript" src="app/lib/angular/angular-scenario.js"></script>

<!-- include source files here... -->
<script src="app/js/phoneControllers.js"></script>

<!-- include spec files here... -->
<script src="test/js/phoneControllersSpec.js"></script>
</head>
<body></body>
</html>

This is 这是

phoneControllers.js phoneControllers.js

function PhoneListCtrl($scope){
$scope.phones=[
    {
        "name":"SamSung",
        "snippet":"Good phone"
    },
    {
        "name":"M",
        "snippet":"Small phone"
    },
    {
        "name":"Apple",
        "snippet":"American phone"
    },
    {
        "name":"BBK",
        "snippet":"Made in China"
    }
];

$scope.Hello="Hello,world";
}

describe("PhoneCat controllers", function(){
describe("PhoneListCtrl", function(){
    var scope={}, ctrl=new PhoneListCtrl(scope);
    it("should create 'phones' model with 4 phones", function(){
        expect(scope.phones.length).toBe(4);
    });

    it("should create 'Hello,world' sentence", function(){
        expect(scope.Hello).toEqual("Hello,world");
    });
});
});

This is my phoneControllersSpec.js 这是我的phoneControllersSpec.js

describe('PhoneCat App', function(){
describe('Phone list view', function(){
    beforeEach(function(){
        browser().navigateTo('../../app/Index.html');
    });

    it('should filter ', function(){
        expect(repeater('.phones li').count()).toBe(4);

        input('query').enter('SamSung');
        expect(repeater('.phones li').count()).toBe(1);

        input('query').enter('China');
        expect(repeater('.phones li').count()).toBe(1);
    });
    });
});

If I remove 如果我删除

<script type="text/javascript" src="app/lib/angular/angular-scenario.js"></script>

from SpecRunning.html, it prompted "browser is not defined". 在SpecRunning.html中,它提示“浏览器未定义”。 What should I do? 我该怎么办? Thanks in advance 提前致谢

Afterwards I resolved this by myself. 之后,我自己解决了这个问题。

  1. We should write test file in a separate html file 我们应该在单独的html文件中编写测试文件
  2. We should make sure the js path is right 我们应该确保js路径正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM