-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Onboarding Playwright (JavaScript and TypeScript) to AzureTestPlanV0 Task #21095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@anshika-gupta21 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
async discoverTests(listOfTestsToBeExecuted: string[], ciData: ciDictionary, listOfTestsToBeRan: string[]): Promise<IOperationResult> { | ||
let operationResult: IOperationResult = { returnCode: 0, errorMessage: '' }; | ||
|
||
listOfTestsToBeExecuted.forEach(element => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: test instead of element
|
||
if (!testsToBeExecuted || testsToBeExecuted.length === 0) { | ||
tl.debug('No tests to execute'); | ||
return { returnCode: 0, errorMessage: 'No tests to execute' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: formatting
let operationResult: IOperationResult = { returnCode: 0, errorMessage: '' }; | ||
let executionTimer = new SimpleTimer(constants.AUTOMATED_EXECUTION); | ||
|
||
tl.debug('Entering executeTests method'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed.
tl.debug(`Executing Playwright test command: ${commandPreview}`); | ||
|
||
operationResult.returnCode = await this.toolRunner.execAsync(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know once changes are done.
case 'javascriptplaywright': | ||
return new PlaywrightTestExecutor(); | ||
case 'typescriptplaywright': | ||
return new PlaywrightTestExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If understand correctly, both are doing the identical work. Can we use a single option instead of providing two?
@@ -73,6 +73,17 @@ export function separateJestTestName(inputString) { | |||
} | |||
} | |||
|
|||
export function separatePlaywrightTestName(inputString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment before the function showcasing input and output of function
|
||
let grepArg = ''; | ||
try { | ||
const junitOutput = 'test-results/test-results.xml'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull out all the code used for setup before the start() function invocation on line 71. In the execution timer, lets track only the time used for executing test not for building the cmdlet.
this.toolRunner.arg('test'); | ||
this.toolRunner.arg('--reporter=junit'); | ||
|
||
if (grepArg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is check required? Since we would have the grep argument each time? In line 66, we already are checking if we have list of valid test cases or not
} | ||
|
||
// Playwright test name selection usually uses 'grep' | ||
if (testsToBeExecuted && testsToBeExecuted.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If condition is redundant since we are checking before hand that testsToBeExecuted is nonnull and nonempty
ciData['executionStatus'] = operationResult.returnCode === 0 ? 'Success' : 'Failure'; | ||
|
||
// Log telemetry data | ||
tl.debug(`Telemetry Data Before Logging: ${JSON.stringify(ciData)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should we log this ?
|
||
this.toolRunnerPath = tl.which(this.testRunnerCLI, true); | ||
this.toolRunner = tl.tool(this.toolRunnerPath); | ||
this.toolRunner.line('install'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check if cross-env is present using tl.which('cross-env', false) and install if not present? since, we will be using cross-env later
|
||
// Playwright test name selection usually uses 'grep' | ||
if (testsToBeExecuted && testsToBeExecuted.length > 0) { | ||
const grepPattern = testsToBeExecuted.map(t => `${t}`).join('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small suggestion on edge case: should we add escape for regex, as in add \ before special characters? for example, if test name is "[test]" it should be passed as "\[test\]" in grepArg to avoid "[", ']" considered as special characters used in regex matching
Task Name: AzureTestPlanV0
Description
Currently, ATP supports four frameworks: JavaMaven, JavaGradle, PyTest, Jest. This PR introduces the integration of the Playwright framework, supporting both JavaScript and TypeScript, with Azure Test Plans (ATP) Task to enhance automated testing capabilities. Playwright is a powerful open-source automation framework that simplifies end-to-end testing across different browsers.
Key Features & Implementation Details:
Demo video: https://microsoftapc-my.sharepoint.com/:v:/g/personal/t-anshgupta_microsoft_com/EZiGK7aFm-9FgpELYZyNQxsBFzmUgRUTh5uVDBeys_drtg?e=IMknGX
The language selection options visible in UI:
Published results on Test tab:
test-results.xml file:
Associated Automation:
Progress Report:
Checklist