e2e 测试未找到规格 angular 2 量角器

e2e test No specs found angular 2 protractor

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

[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

尝试使用套件:

/*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
    }
};

也许您应该研究一下页面对象设计模式:

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);
        });
    });
});

很简单:

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

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