Last active
June 23, 2023 05:42
-
-
Save vasylnahuliak/5d19144d348b934064fa657615413d08 to your computer and use it in GitHub Desktop.
Generating unique testID
This file contains hidden or 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
type GetTestIDArgs<TestID> = { | |
testID: TestID; | |
prefix: string; | |
} | |
export const getTestID = <TestID extends Record<string, string>>({ | |
testID, | |
prefix, | |
}: GetTestIDArgs<TestID>): TestID => { | |
return new Proxy(testID, { | |
get: (obj, prop: string) => { | |
return prefix ? `${prefix}_${obj[prop]}` : obj[prop]; | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Генерація унікальних testID для E2E тестування