[英]Electron,Spectron: how to write test cases in seperate javascript file
我正在測試使用這些技術的電子應用程序,如Spectron,Chai,chai所承諾的,我希望將我的測試用例編寫在單獨的文件中,除了全部都在一個文件中。
這是我嘗試過的
describe("Login", function () {
this.timeout(10000);
//Case 1: wait for Electron window to open
it('open window', function () {
return app.client.waitUntilWindowLoaded().getWindowCount().should.eventually.equal(1);
});
//Case 2: Initial Login - Empty username & Password
it("Click on Login Without any Data", function () {
//Wait for window to load
return app.client.waitUntilWindowLoaded()
.setValue(usernametxt, "")
.setValue(passwordtxt, "")
.click(submitbtn)
.getText('.notification-content')
.should.eventually.equal("Please fill both username and password");
});
});
我只是想將案例1和案例2寫入測試初始化文件中的單獨文件中。
只需創建兩個規范文件即可將測試分開:
spec1.js
spec2.js
創建一個包含以下內容的.js文件(test.js):
require('spec1')
require('spec2')
在package.json中,請在mocha test命令中參考test.js:
"scripts": {
"test": "mocha test/test.js"
}
考慮到您有一個測試文件夾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.