e2e test没有找到规格有角度的2量角器

时间:2017-07-14 08:18:16

标签: angular typescript protractor e2e-testing

我的量角器测试有问题,它总是会抛出一条消息:

[10:11:22] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[10:11:22] I/launcher - Running 1 instances of WebDriver
Started
No specs found
Finished in 0.001 seconds
[10:11:24] I/launcher - 0 instance(s) of WebDriver still running
[10:11:24] I/launcher - firefox #01 passed
http-server stopped.

配置文件很好,它会读取e2e文件。有配置文件:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    baseURL: 'http://localhost:3000/',
    capabilities: {
        'browserName': 'firefox'
    },
    specs: ['e2e-spec.ts'],
    jasmineNodeOpts: {
        showColors: true
    }
};

我的e2e档案:

// app.e2e-spec.ts
import { Registration } from './registrationPage';
import {browser} from "protractor";

describe('e2e-spec.ts', function() {
    let page: Registration;
    let header = 'Welcome!';
    page = new Registration();
    let result = page.getHeader();
        it('should display heading saying Welcome!', () => {
        page.navigateTo().then(function () {
            console.log('Start test 1: automatic redirection of index');
            expect(result).toEqual(header);
        });
    });
});

我不知道该怎么做,我把它放入e2e文件并不重要,它打开浏览器,关闭它并一直抛出相同的消息,我使用npm run e2e

2 个答案:

答案 0 :(得分:1)

尝试使用套件:

/*let suites = {
  e2e: "./*e2e-spec.ts"
};*/

//Bruteforce to find the path

let suites = { 
  e2e2: "../**/*spec.ts" 
};

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    baseURL: 'http://localhost:3000/',
    capabilities: {
        'browserName': 'firefox'
    },
    suites: suites,
    jasmineNodeOpts: {
        showColors: true
    }
};

也许你应该研究Page Object Dessign模式:

let RegistrationPage = require('./registrationPage');

describe('e2e-spec.ts', function() {
    let page = new RegistrationPage();
    let result = page.getHeader();
    let header = 'Welcome!';

    it('should display heading saying Welcome!', () => {
        page.navigateTo().then(function () {
            console.log('Start test 1: automatic redirection of index');
            expect(result).toEqual(header);
        });
    });
});

答案 1 :(得分:0)

这很简单:

specs: [
'./e2e/**/*.e2e-spec.ts'
]

这意味着它将在e2e文件夹中运行所有测试用例(.e2e-spec.ts)。

enter image description here