11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license. See LICENSE file in the project root for details.
33
4- import { Page } from "playwright" ;
5- import { SmokeTestLogger } from "./helper/smokeTestLogger" ;
6- import { app , screenshots } from "./main" ;
74import * as assert from "assert" ;
85import { ComponentHelper } from "./helper/componentHelper" ;
96import { ElementHelper } from "./helper/elementHelper" ;
107import { Element } from "./helper/constants" ;
8+ import { BaseSmokeTest } from "./helper/baseSmokeTest" ;
9+ import { SmokeTestLogger } from "./helper/smokeTestLogger" ;
1110import { TimeoutConstants } from "./helper/timeoutConstants" ;
1211
1312export function startCDPNodeVersionCompatibilityTests ( ) : void {
1413 describe ( "CDPNodeVersionCompatibilityTest" , ( ) => {
15- async function initApp ( ) : Promise < Page > {
16- await app . launch ( ) ;
17- return app . getMainPage ( ) ;
18- }
19-
20- async function dispose ( ) {
21- if ( this . currentTest ?. state === "failed" ) {
22- SmokeTestLogger . info ( "Test failed, taking screenshot ..." ) ;
23- await screenshots . takeScreenshots (
24- this . currentTest . parent ?. title || "Others" ,
25- this . currentTest . title . replace ( / \s + / g, "_" ) ,
26- ) ;
27- }
28- try {
29- SmokeTestLogger . info ( `Dispose test: "${ this . currentTest . title } " ...` ) ;
30- if ( app ) {
31- await app . close ( ) ;
32- }
33- } catch ( error ) {
34- SmokeTestLogger . error ( `Error while dispose: ${ error } ` ) ;
35- }
36- }
37-
38- afterEach ( dispose ) ;
14+ afterEach ( BaseSmokeTest . dispose ) ;
3915
4016 it ( "Verify Run and Debug tab is accessible for debugging operations" , async ( ) => {
41- await initApp ( ) ;
17+ await BaseSmokeTest . initApp ( ) ;
4218
4319 await ComponentHelper . openRunAndDebugTab ( ) ;
4420 await ElementHelper . WaitElementClassNameVisible (
@@ -50,7 +26,7 @@ export function startCDPNodeVersionCompatibilityTests(): void {
5026 } ) ;
5127
5228 it ( "Verify command palette can access debug-related commands" , async ( ) => {
53- await initApp ( ) ;
29+ await BaseSmokeTest . initApp ( ) ;
5430
5531 await ComponentHelper . openCommandPalette ( ) ;
5632 await ElementHelper . WaitElementClassNameVisible (
@@ -70,7 +46,7 @@ export function startCDPNodeVersionCompatibilityTests(): void {
7046 } ) ;
7147
7248 it ( "Verify React Native packager is available for debugging" , async ( ) => {
73- await initApp ( ) ;
49+ await BaseSmokeTest . initApp ( ) ;
7450
7551 await ComponentHelper . getReactNativePackager ( ) ;
7652 SmokeTestLogger . info ( "React Native packager is available for debugging" ) ;
0 commit comments