-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathtest.js
More file actions
74 lines (61 loc) · 2.47 KB
/
test.js
File metadata and controls
74 lines (61 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const assert = require('assert');
describe("BStackDemo Tests Module A", () => {
before(async () => {
var textButton = await $(`~Text Button`);
await textButton.waitForDisplayed({ timeout: 30000 });
await textButton.click();
var textInput = await $(`~Text Input`);
await textInput.waitForDisplayed({ timeout: 30000 });
await textInput.click()
await textInput.addValue("hello@browserstack.com"+"\n");
var textOutput = await $(`~Text Output`);
await textOutput.waitForDisplayed({ timeout: 30000 });
var value = await textOutput.getText();
});
it("flaky test - passes and fails intermittently", async () => {
assert(Math.random() > 0.3, 'Flaky test failed');
});
it("always failing test - missing element 1", async () => {
// Try to click a non-existent element, which should fail
const nonExistent = await $(`~non-existent-1`);
await nonExistent.waitForDisplayed({ timeout: 3000 });
await nonExistent.click(); // Will fail
});
it("always passing test - example C", async () => {
assert.equal(true, true);
});
it("always failing test - same stacktrace 1", async () => {
// Try to click a non-existent element, which should fail (same selector as below)
const nonExistent = await $(`~common-error`);
await nonExistent.waitForDisplayed({ timeout: 3000 });
await nonExistent.click(); // Will fail
});
it("always failing test - same stacktrace 2", async () => {
const nonExistent = await $(`~common-error`);
await nonExistent.waitForDisplayed({ timeout: 3000 });
await nonExistent.click(); // Will fail
});
it("always passing test - example D", async () => {
assert.equal(true, true);
});
it("always passing test - example A", async () => {
assert.strictEqual(1 + 1, 2, 'This test should always pass');
});
it("Test with framework-level retry - 2 retries configured", function () {
this.retries(2); // Framework-level retry
const randomOutcome = Math.random() > 0.7;
if (!randomOutcome) {
throw new Error("Test failed, retrying...");
}
});
it("Another Test with framework-level retry - 2 retries configured", function () {
this.retries(2); // Framework-level retry
const randomOutcome = Math.random() > 0.7;
if (!randomOutcome) {
throw new Error("Test failed, retrying...");
}
});
it("always passing test - example B", async () => {
assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass');
});
});