What is the process of setting up Playwright for desktop app testing with Node.js and TypeScript?


Setting up Playwright for Desktop App Testing

To set up Playwright for desktop app testing with Node.js and TypeScript, follow these steps:

  1. Install dependencies: Install Playwright and its test runner, @playwright/test, using npm or yarn:

    npm install playwright @playwright/test
  2. Create a tsconfig.json file: Inside the tests directory, create a tsconfig.json file and configure it accordingly:

      "compilerOptions": {
        "target": "ESNext",
        "module": "commonjs",
        "strict": true,
        "esModuleInterop": true,
        "outDir": "tests-out"
      "include": ["tests"]
  3. Update package.json: Add two scripts to your package.json file: pretest and test. The pretest script runs TypeScript on the tests, while test runs the generated tests in the tests-out directory:

    "scripts": {
      "pretest": "tsc",
      "test": "playwright test tests-out"
  4. Write a test: Create a test file, e.g., mytest.spec.ts, and write a simple test using Playwright:

    import { test, expect } from '@playwright/test';
    test('Check Ray homepage', async ({ page }) => {
      await page.goto('https://ray.run/');
      const title = await page.title();
  5. Run the test: Execute your test using the following command:

    npm test

Now you have successfully set up Playwright for desktop app testing with Node.js and TypeScript. Remember, Playwright runs browsers in headless mode by default. To see the browser UI, pass the headless: false flag when launching the browser. You can also use the slowMo option to slow down execution if needed.

For more tips and best practices, check out Tips for Writing Efficient Playwright Test Scripts and Mastering Playwright Test Automation: Your Comprehensive Cheat Sheet.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

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.