Rayrun
← Back to Discord Forum

VSCode Setup for Playwright JavaScript

I am facing with my VSCode setup. When I am using fixtures in playwright, the VSCode intellisense is not suggesting me the functions defined inside the fixture class. I am not able to click into the function unless i define it locally within that method. Is anyone else faced this issue with VScode. If yes, it would really be helpful if anyone can suggest any solution to this. Example -- Login.test.js

import test from '@lib/BaseTest';

// We can use Steps like in Cucmber format as shown below

test(@Smoke Verify Book Store Login, async ({ loginPage, webActions }) => { await test.step(Navigate to Application, async () => { await loginPage.navigateToURL(); });

await test.step(Click on Book Store Application Icon, async () => { await webActions.clickByText('Book Store Application'); }); }); BaseTest.js const test = baseTest.extend({ webActions: async ({ page, context }, use) => { await use(new WebActions(page, context)); }, loginPage: async ({ page, context }, use) => { await use(new LoginPage(page, context)); }, When i "cmd+click" on loginPage."navigateToURL: which is defined in LoginPage class, I am not able to go in. VSCode is not identifying or suggesting me these functions when i type "loginPage. ".. P.S. Execution is working fine. please help

This thread is trying to answer question "How to resolve the issue of VSCode intellisense not suggesting functions defined inside the fixture class in Playwright?"

4 replies

VSCode Setup for Playwright JavaScript

@here

I'd suggest switching to TypeScript (it's the Playwright dev team's preference too). Mostly that involves renaming all files from .js to .ts, and updating the playwright.config.ts to look for tests with the .ts extension.

Playwright will take care of on-the-fly transpilation behind the scenes for you (using Babel).

When creating fixtures with .ts, then you need to add a bit more type information, just follow the TypeScript fixtures examples from this page: https://playwright.dev/docs/test-fixtures

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.