@@ -1881,3 +1881,61 @@ test('should list tests in the right order', async ({ runInlineTest, showReport,
18811881 / m a i n › s e c o n d › p a s s e s \d + m ? s s e c o n d .t s : 5 / ,
18821882 ] ) ;
18831883} ) ;
1884+
1885+ test ( 'tests should filter by file' , async ( { runInlineTest, showReport, page } ) => {
1886+ const result = await runInlineTest ( {
1887+ 'file-a.test.js' : `
1888+ const { test } = require('@playwright/test');
1889+ test('a test 1', async ({}) => {});
1890+ test('a test 2', async ({}) => {});
1891+ ` ,
1892+ 'file-b.test.js' : `
1893+ const { test } = require('@playwright/test');
1894+ test('b test 1', async ({}) => {});
1895+ test('b test 2', async ({}) => {});
1896+ ` ,
1897+ } , { reporter : 'dot,html' } , { PW_TEST_HTML_REPORT_OPEN : 'never' } ) ;
1898+
1899+ expect ( result . exitCode ) . toBe ( 0 ) ;
1900+ expect ( result . passed ) . toBe ( 4 ) ;
1901+ expect ( result . failed ) . toBe ( 0 ) ;
1902+
1903+ await showReport ( ) ;
1904+
1905+ const searchInput = page . locator ( '.subnav-search-input' ) ;
1906+
1907+ await searchInput . fill ( 'file-a' ) ;
1908+ await expect ( page . getByText ( 'file-a.test.js' , { exact : true } ) ) . toBeVisible ( ) ;
1909+ await expect ( page . getByText ( 'a test 1' ) ) . toBeVisible ( ) ;
1910+ await expect ( page . getByText ( 'a test 2' ) ) . toBeVisible ( ) ;
1911+ await expect ( page . getByText ( 'file-b.test.js' , { exact : true } ) ) . not . toBeVisible ( ) ;
1912+ await expect ( page . getByText ( 'b test 1' ) ) . not . toBeVisible ( ) ;
1913+ await expect ( page . getByText ( 'b test 2' ) ) . not . toBeVisible ( ) ;
1914+
1915+ await searchInput . fill ( 'file-a:3' ) ;
1916+ await expect ( page . getByText ( 'a test 1' ) ) . toBeVisible ( ) ;
1917+ await expect ( page . getByText ( 'a test 2' ) ) . not . toBeVisible ( ) ;
1918+ } ) ;
1919+
1920+ test ( 'tests should filter by status' , async ( { runInlineTest, showReport, page } ) => {
1921+ const result = await runInlineTest ( {
1922+ 'a.test.js' : `
1923+ const { test, expect } = require('@playwright/test');
1924+ test('failed title', async ({}) => { expect(1).toBe(1); });
1925+ test('passes title', async ({}) => { expect(1).toBe(2); });
1926+ ` ,
1927+ } , { reporter : 'dot,html' } , { PW_TEST_HTML_REPORT_OPEN : 'never' } ) ;
1928+
1929+ expect ( result . exitCode ) . toBe ( 1 ) ;
1930+ expect ( result . passed ) . toBe ( 1 ) ;
1931+ expect ( result . failed ) . toBe ( 1 ) ;
1932+
1933+ await showReport ( ) ;
1934+
1935+ const searchInput = page . locator ( '.subnav-search-input' ) ;
1936+
1937+ await searchInput . fill ( 's:failed' ) ;
1938+ await expect ( page . getByText ( 'a.test.js' , { exact : true } ) ) . toBeVisible ( ) ;
1939+ await expect ( page . getByText ( 'failed title' ) ) . not . toBeVisible ( ) ;
1940+ await expect ( page . getByText ( 'passes title' ) ) . toBeVisible ( ) ;
1941+ } ) ;
0 commit comments