Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/wdio-ui5-lts/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const url = `https://ui5.sap.com/${ui5Version}/test-resources/sap/m/demokit/orde

export const config = {
wdi5: {
logLevel: "verbose"
logLevel: "verbose",
// Increase timeout to handle "waitAsync is already running" errors
waitforui5Timeout: 30000
},
baseUrl: url,

Expand Down
12 changes: 10 additions & 2 deletions src/lib/authentication/Authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@ export default class Authenticator {
if (browser.isMultiremote) {
envName = `wdi5_${this.browserInstanceName}_username`
}
return process.env[envName] || ""
const sUserName = process.env[envName]
if (!sUserName) {
throw new Error(`Environment variable ${envName} for username is not set!`)
}
return sUserName
}

getPassword(): string {
let envName = "wdi5_password"
if (browser.isMultiremote) {
envName = `wdi5_${this.browserInstanceName}_password`
}
return process.env[envName] || ""
const sPassword = process.env[envName]
if (!sPassword) {
throw new Error(`Environment variable ${envName} for password is not set!`)
}
return sPassword
}

async getIsLoggedIn(): Promise<boolean> {
Expand Down
28 changes: 28 additions & 0 deletions test/Authenticator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Authenticator from "../src/lib/authentication/Authenticator.js"
import { throws } from "node:assert"

describe("base authenticator", function () {
before(function () {
globalThis.browser = { isMultiremote: false }
})

after(function () {
globalThis.browser = null
})

it("should throw if username is not provided", function () {
const auth = new Authenticator("fake")
throws(() => auth.getUsername(), {
name: /Error/,
message: /for username is not set/
})
})

it("should throw if password is not provided", function () {
const auth = new Authenticator("fake")
throws(() => auth.getPassword(), {
name: /Error/,
message: /for password is not set/
})
})
})
Loading