@@ -3,15 +3,28 @@ import { expect, test } from '@playwright/test'
33const HOME = '/'
44
55test . describe ( 'Component - Dev tools' , ( ) => {
6- const DEV_TOOLS = 'tailwind-indicator'
6+ test . beforeEach ( async ( { page } ) => {
7+ try {
8+ await page . waitForLoadState ( )
9+ } catch ( error ) {
10+ console . error ( error )
11+ }
12+ } )
13+ try {
14+ const DEV_TOOLS = 'tailwind-indicator'
715
8- test ( 'Expected - Tailwind indicator to not be rendered' , async ( { page } ) => {
9- await page . goto ( HOME )
16+ test ( 'Expected - Tailwind indicator to not be rendered' , async ( {
17+ page,
18+ } ) => {
19+ await page . goto ( HOME )
1020
11- const twIndicator = await page . getByTestId ( DEV_TOOLS ) . count ( )
21+ const twIndicator = await page . getByTestId ( DEV_TOOLS ) . count ( )
1222
13- expect ( twIndicator ) . toBe ( 0 )
14- } )
23+ expect ( twIndicator ) . toBe ( 0 )
24+ } )
25+ } catch ( error ) {
26+ console . error ( error )
27+ }
1528} )
1629
1730test . describe ( 'Component - Marquee' , ( ) => {
@@ -30,50 +43,73 @@ test.describe('Component - Marquee', () => {
3043 'AWS' ,
3144 ]
3245
46+ test . beforeEach ( async ( { page } ) => {
47+ try {
48+ await page . waitForLoadState ( )
49+ } catch ( error ) {
50+ console . error ( error )
51+ }
52+ } )
53+
3354 test ( 'Expected - Marquee to be visible' , async ( { page } ) => {
34- await page . goto ( HOME )
55+ try {
56+ await page . goto ( HOME )
3557
36- const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
58+ const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
3759
38- await expect ( PAGE_LOCATOR ) . toBeVisible ( )
60+ await expect ( PAGE_LOCATOR ) . toBeVisible ( )
61+ } catch ( error ) {
62+ console . log ( error )
63+ }
3964 } )
4065 test ( 'Expected - Correct height and width, 70px 100vw' , async ( { page } ) => {
41- await page . goto ( HOME )
66+ try {
67+ await page . goto ( HOME )
4268
43- const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
69+ const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
4470
45- const marquee = await PAGE_LOCATOR . boundingBox ( )
71+ const marquee = await PAGE_LOCATOR . boundingBox ( )
4672
47- const viewPort = page . viewportSize ( )
73+ const viewPort = page . viewportSize ( )
4874
49- if ( viewPort === null ) throw new Error ( 'Viewport is null' )
75+ if ( viewPort === null ) throw new Error ( 'Viewport is null' )
5076
51- const { width } = viewPort
77+ const { width } = viewPort
5278
53- expect ( marquee ?. width ) . toBe ( width )
54- expect ( marquee ?. height ) . toBe ( MARQUEE_HEIGHT )
79+ expect ( marquee ?. width ) . toBe ( width )
80+ expect ( marquee ?. height ) . toBe ( MARQUEE_HEIGHT )
81+ } catch ( error ) {
82+ console . error ( error )
83+ }
5584 } )
5685
5786 test ( 'Expected - Total images number' , async ( { page } ) => {
58- await page . goto ( HOME )
87+ try {
88+ await page . goto ( HOME )
5989
60- const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
61- const marqueeImages = PAGE_LOCATOR . locator ( 'img' )
90+ const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
91+ const marqueeImages = PAGE_LOCATOR . locator ( 'img' )
6292
63- expect ( await marqueeImages . count ( ) ) . toBe ( TOTAL_IMAGES )
93+ expect ( await marqueeImages . count ( ) ) . toBe ( TOTAL_IMAGES )
94+ } catch ( error ) {
95+ console . error ( error )
96+ }
6497 } )
6598
6699 test ( 'Expected - All images to be visible' , async ( { page } ) => {
67- await page . goto ( HOME )
68-
69- const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
70-
71- const marqueeImages = await PAGE_LOCATOR . locator ( 'img' ) . all ( )
72-
73- for ( const image of marqueeImages ) {
74- const alt = await image . getAttribute ( 'alt' )
75- expect ( image ) . toBeVisible ( )
76- expect ( MARQUEE_IMAGES ) . toContain ( alt )
100+ try {
101+ await page . goto ( HOME )
102+ const PAGE_LOCATOR = page . locator ( 'div' ) . filter ( { hasText : MARQUEE_SPAN } )
103+
104+ const marqueeImages = await PAGE_LOCATOR . locator ( 'img' ) . all ( )
105+
106+ for ( const image of marqueeImages ) {
107+ const alt = await image . getAttribute ( 'alt' )
108+ await expect ( image ) . toBeVisible ( )
109+ expect ( MARQUEE_IMAGES ) . toContain ( alt )
110+ }
111+ } catch ( error ) {
112+ console . error ( error )
77113 }
78114 } )
79115} )
0 commit comments