stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.72k stars 83 forks source link

TypeScript Playwright support #321

Closed kdnk closed 11 months ago

kdnk commented 11 months ago

Language: TypeScript

Example: https://playwright.dev/docs/writing-tests

import { test, expect } from '@playwright/test';

test.describe('navigation', () => {
  test.beforeEach(async ({ page }) => {
    // Go to the starting url before each test.
    await page.goto('https://playwright.dev/');
  });

  test('main navigation', async ({ page }) => {
    // Assertions use the expect API.
    await expect(page).toHaveURL('https://playwright.dev/');
  });
});

In https://github.com/stevearc/aerial.nvim/issues/47, Jest is supported, but sometimes aerial.nvim doesn't work as expected with Playwright. In Playwright we usually use test.describe instead of describe but it doesn't show up on aerial window. test.describe should be treated as the same with describe.

Slotos commented 11 months ago

Create a file after/queries/typescript/aerial.scm in your vim configuration directory with the following contents:

;; extends

(call_expression
  function: (_
              property: (property_identifier) @method @name (#any-of? @method "describe" "beforeEach"))
  arguments: (arguments
    (string
      (string_fragment) @name @string))?
  (#set! "kind" "Function")
  ) @symbol @selection

If more test.<something> cases need to be matched, expand the #any-of? list.

kdnk commented 11 months ago

@Slotos Thank you! It works!