@@ -105,11 +105,27 @@ Inside that directory, you can run:
105105
106106export const writeTestExample = async ( dirPath : string , ext : Language ) : Promise < void > => {
107107 const testExample = `
108- describe("test", () => {
109- it("example ", async ({browser}) => {
110- await browser.url ("https://github.com/gemini-testing/testplane ");
108+ describe("test examples ", () => {
109+ it("docs search test ", async ({browser}) => {
110+ await browser.openAndWait ("https://testplane.io/ ");
111111
112- await expect(browser.$(".f4.my-3")).toHaveText("Testplane (ex-hermione) browser test runner based on mocha and wdio");
112+ // Find by tag name
113+ const navBar = await browser.$("nav");
114+
115+ // Find by aria-label
116+ await navBar.$("aria/Search").click();
117+
118+ // Find by placeholder
119+ const fileSearchInput = await browser.findByPlaceholderText("Search docs");
120+ await fileSearchInput.setValue("config");
121+
122+ // Find by id
123+ const fileSearchResults = await browser.$("#docsearch-list");
124+
125+ // Find by role
126+ const fileSearchResultsItems = await fileSearchResults.findAllByRole("option");
127+
128+ expect(fileSearchResultsItems.length).toBeGreaterThan(1);
113129 });
114130});
115131` ;
@@ -145,11 +161,31 @@ export const addModule = (
145161
146162export const asExpression = ( value : string ) : string => `__expression: ${ value } ` ;
147163
164+ export const connectTestingLibraryToTestplaneConfig = ( config : TestplaneConfig ) : void => {
165+ addModule ( config , "{ setupBrowser }" , "@testplane/testing-library" ) ;
166+
167+ if ( config . __language === "js" ) {
168+ const prepareBrowserJsFunction = asExpression ( "browser => { setupBrowser(browser) }" ) ;
169+
170+ _ . set ( config , "prepareBrowser" , prepareBrowserJsFunction ) ;
171+ } else if ( config . __language === "ts" ) {
172+ addModule ( config , "type { WdioBrowser }" , "testplane" ) ;
173+
174+ const prepareBrowserTsFunction = asExpression ( "(browser: WdioBrowser) => { setupBrowser(browser) }" ) ;
175+
176+ _ . set ( config , "prepareBrowser" , prepareBrowserTsFunction ) ;
177+ }
178+ } ;
179+
148180export const extendWithTypescript = async ( packageNamesToInstall : string [ ] , appPath : string ) : Promise < void > => {
149181 packageNamesToInstall . push ( "typescript" ) ;
150182
151183 const testplaneTsConfigPath = path . join ( appPath , defaultTestplaneTestsDir , "tsconfig.json" ) ;
152- const defaultTestplaneTsConfig = _ . set ( { } , [ "compilerOptions" , "types" ] , [ "testplane" ] ) ;
184+ const defaultTestplaneTsConfig = _ . set (
185+ { } ,
186+ [ "compilerOptions" , "types" ] ,
187+ [ "testplane" , "@testplane/testing-library" ] ,
188+ ) ;
153189
154190 await fsUtils . writeJson ( testplaneTsConfigPath , defaultTestplaneTsConfig ) ;
155191} ;
0 commit comments