@@ -9,10 +9,9 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
99const envPath = path . resolve ( process . cwd ( ) , 'envs/.env.dev' ) ;
1010dotenv . config ( { path : envPath } ) ;
1111
12- // --- DEBUG DE NODE.JS (Para pegar o erro oculto) ---
12+ // --- DEBUG DE NODE.JS ---
1313process . on ( 'unhandledRejection' , ( reason , promise ) => {
1414 console . error ( '🔥 CRITICAL: Unhandled Rejection at:' , promise , 'reason:' , reason ) ;
15- // Não damos exit(1) aqui para não falhar o teste se for um erro bobo de analytics
1615} ) ;
1716
1817let browser : Browser ;
@@ -41,25 +40,42 @@ Before(async function (scenario) {
4140 const scenarioName = scenario . pickle . name ;
4241 console . log ( `[Hooks] ▶️ Cenário: ${ scenarioName } ` ) ;
4342
44- // Configuração do contexto por cenário (Isolamento)
43+ // ============================================================
44+ // 🏷️ A MÁGICA DAS SUÍTES (RESTAURADA)
45+ // Isso garante que o Allure organize os testes nas pastinhas certas
46+ // ============================================================
47+ // O 'this' aqui é o World do Cucumber, que o Allure extende
48+ if ( this . label ) {
49+ this . label ( "framework" , "cucumberjs" ) ;
50+ this . label ( "language" , "typescript" ) ;
51+
52+ // Nível 1: Pasta Raiz (Ex: "E2E Web")
53+ this . label ( "parentSuite" , "E2E Web" ) ;
54+
55+ // Nível 2: Nome da Funcionalidade (Ex: "Login")
56+ this . label ( "suite" , featureName ) ;
57+
58+ // Nível 3: Nome do Cenário (Ex: "Login com sucesso")
59+ this . label ( "subSuite" , scenarioName ) ;
60+ }
61+ // ============================================================
62+
4563 context = await browser . newContext ( {
4664 ignoreHTTPSErrors : true ,
47- viewport : { width : 1280 , height : 720 } , // Tamanho padrão evita erros de responsividade
65+ viewport : { width : 1280 , height : 720 } ,
4866 locale : 'en-US'
4967 } ) ;
5068
5169 const page = await context . newPage ( ) ;
5270 this . page = page ;
5371 this . pageManager = new PageManager ( this . page ) ;
5472
55- // Link para o Allure (se disponível)
5673 if ( this . attach ) {
5774 this . pageManager . setAllureAttach ( this . attach . bind ( this ) ) ;
5875 }
5976} ) ;
6077
6178After ( async function ( scenario ) {
62- // 1. Tira Screenshot em caso de falha
6379 if ( scenario . result ?. status === Status . FAILED ) {
6480 if ( this . page ) {
6581 try {
@@ -71,7 +87,6 @@ After(async function (scenario) {
7187 }
7288 }
7389
74- // 2. Limpeza do Contexto (Safe Close)
7590 try {
7691 if ( this . page && ! this . page . isClosed ( ) ) await this . page . close ( ) ;
7792 if ( context ) await context . close ( ) ;
@@ -88,10 +103,6 @@ AfterAll(async function () {
88103 console . warn ( `[Hooks] Erro ao fechar browser: ${ e } ` ) ;
89104 }
90105
91- // -----------------------------------------------------------
92- // O SEGREDO DO CI: Forçar saída limpa após os testes
93- // Isso mata processos "zumbis" do Playwright que causam Exit 1
94- // -----------------------------------------------------------
95106 if ( process . env . CI === 'true' ) {
96107 console . log ( '[Hooks] 🏁 CI Detectado: Forçando Exit Code 0...' ) ;
97108 setTimeout ( ( ) => process . exit ( 0 ) , 500 ) ;
0 commit comments