-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from katalon-studio-samples/TO-1429
[TO-1429] Create protractor mocha sample
- Loading branch information
Showing
6 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "testops-protractor-mocha-sample", | ||
"version": "1.0.0", | ||
"description": "TestOps Protractor Mocha sample", | ||
"scripts": { | ||
"build": "tsc", | ||
"pretest": "npm run cleanup && npm run build && npm run update-webdriver", | ||
"test": "protractor", | ||
"cleanup": "rimraf dist", | ||
"update-webdriver": "webdriver-manager update" | ||
}, | ||
"author": "Katalon, LLC. (https://www.katalon.com)", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@katalon/testops-mocha": "latest", | ||
"@katalon/testops-protractor": "latest", | ||
"chai": "^4.3.4", | ||
"chai-as-promised": "^7.1.1" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node10": "^1.0.7", | ||
"@types/chai": "^4.2.14", | ||
"@types/chai-as-promised": "^7.1.3", | ||
"@types/mocha": "^8.2.2", | ||
"mocha": "^8.2.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
exports.config = { | ||
framework: "mocha", | ||
specs: ["./dist/tests/*.js"], | ||
capabilities: { | ||
browserName: "chrome", | ||
args: ["--headless", "--disable-dev-shm-usage", "--no-sandbox"], | ||
}, | ||
plugins: [ | ||
{ | ||
package: "@katalon/testops-protractor", | ||
}, | ||
], | ||
mochaOpts: { | ||
timeout: "20s", | ||
reporter: "@katalon/testops-mocha", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"apiKey": "", | ||
"basePath": "", | ||
"projectId": "", | ||
"reportFolder": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { browser, element, by } from "protractor"; | ||
import { ElementFinder } from "protractor/built"; | ||
import chai from "chai"; | ||
import chaiAsPromised from "chai-as-promised" | ||
|
||
chai.use(chaiAsPromised); | ||
const expect = chai.expect; | ||
|
||
describe("slow calculator", function () { | ||
beforeEach(function () { | ||
browser.get("https://juliemr.github.io/protractor-demo/"); | ||
}); | ||
|
||
it("should add numbers", function () { | ||
element(by.model("first")).sendKeys(4); | ||
element(by.model("second")).sendKeys(5); | ||
|
||
element(by.id("gobutton")).click(); | ||
|
||
expect(element(by.binding("latest")).getText()).to.eventually.equal("9"); | ||
}); | ||
|
||
describe("memory", function () { | ||
let first: ElementFinder, second: ElementFinder, goButton: ElementFinder; | ||
beforeEach(function () { | ||
first = element(by.model("first")); | ||
second = element(by.model("second")); | ||
goButton = element(by.id("gobutton")); | ||
}); | ||
|
||
it("should start out with an empty memory", function () { | ||
const memory = element.all(by.repeater("result in memory")); | ||
|
||
expect(memory.count()).to.eventually.equal(0); | ||
}); | ||
|
||
it("should fill the memory with past results", function () { | ||
first.sendKeys(1); | ||
second.sendKeys(1); | ||
goButton.click(); | ||
|
||
first.sendKeys(10); | ||
second.sendKeys(20); | ||
goButton.click(); | ||
|
||
const memory = element.all( | ||
by.repeater("result in memory").column!("result.value") | ||
); | ||
memory.then(function (arr) { | ||
expect(arr.length).to.equal(2); | ||
expect(arr[0].getText()).to.eventually.equal("30"); // 10 + 20 = 30 | ||
expect(arr[1].getText()).to.eventually.equal("2"); // 1 + 1 = 2 | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "./dist", | ||
|
||
// Include source maps for Jest | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
|
||
"allowSyntheticDefaultImports": true, | ||
"allowJs": true | ||
}, | ||
"extends": "@tsconfig/node10/tsconfig.json", | ||
"exclude": [ | ||
"./dist" | ||
] | ||
} |