2017-07-14 137 views
1

我有與量角器測試問題,它總是拋出一個消息:端對端測試沒有發現規格角2量角器

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

我端對端文件:

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

我不知道該怎麼辦,沒關係我投入端對端文件,它會打開瀏覽器,關閉它,拋出所有的時間相同的消息,我用npm run e2e

回答

1

使用try套房:

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

也許你應該考慮的頁面對象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); 
     }); 
    }); 
}); 
+0

還是同樣的消息沒有找到規格@ –

+0

JędrekMarkowski還好吧,蠻力:試試這個:'讓套房= { E2E: 「./*spec.ts」, E2E2:」 ../* spec.ts「, e2e2e:」./**/*spec.ts「, e2e2e2:」../**/*spec.ts「 };' – Alf

+0

如果您發佈測試路徑的截圖。所以我們可以找出正確的路徑。 – Alf

0

這很簡單:

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

這意味着它將運行端對端文件夾中的所有測試用例(.e2e-spec.ts)。

enter image description here