80 lines
2.6 KiB
Markdown
80 lines
2.6 KiB
Markdown
# PlayWrong Test Language Extension
|
|
|
|
A VSCode extension that provides syntax highlighting and real-time linting for PlayWrong test files (`.test` extension).
|
|
|
|
## Features
|
|
|
|
### Syntax Highlighting
|
|
- Commands: `use`, `open`, `wait`, `click`, `scroll`, `fill`, `break`, `sleep`, `dump`
|
|
- Parameters: `element`, `name`, `id`, `class`, `href`, `type`, `childText`, `value`
|
|
- Strings with environment variable support (`$VARIABLE`)
|
|
- Comments: `//`, `#`, `/* */`
|
|
- Numbers and HTML elements
|
|
|
|
### Real-time Linting
|
|
- **Errors**: Invalid commands, syntax errors, missing parameters
|
|
- **Warnings**: Semantic issues, best practice violations
|
|
- **Info**: Helpful suggestions and environment variable usage
|
|
|
|
### Commands
|
|
- **PlayWrong: Lint PlayWrong Test File** - Run linter on current file
|
|
- **PlayWrong: Lint PlayWrong Test File (Strict)** - Run linter with warnings as errors
|
|
|
|
## Usage
|
|
|
|
1. Open any `.test` file in VSCode
|
|
2. The extension will automatically:
|
|
- Apply syntax highlighting
|
|
- Show real-time linting feedback in the Problems panel
|
|
- Underline errors, warnings, and info messages in the editor
|
|
|
|
3. Right-click in a `.test` file to access linting commands from the context menu
|
|
|
|
## Installation
|
|
|
|
This extension is automatically loaded when you open this workspace. The `.test` files will be automatically associated with the PlayWrong language.
|
|
|
|
## Example
|
|
|
|
```test
|
|
use "Chrome"
|
|
open "https://example.com"
|
|
wait element=button childText="Login"
|
|
click element=button childText="Login"
|
|
fill element=input type="email" value="user@example.com"
|
|
sleep 2000 "login processing"
|
|
dump "login_page"
|
|
```
|
|
|
|
## Linting Rules
|
|
|
|
### Errors
|
|
- Invalid commands
|
|
- Unclosed quotes
|
|
- Missing required parameters
|
|
|
|
### Warnings
|
|
- Unknown HTML elements
|
|
- Generic element selectors
|
|
- Semantic misuse (e.g., `click` on input fields)
|
|
- **Undefined variables**: Variables that are not commonly defined environment variables
|
|
|
|
### Info
|
|
- Environment variable usage
|
|
- Command placement suggestions
|
|
- Best practice tips
|
|
|
|
## Variable Validation
|
|
|
|
The extension now provides enhanced validation for environment variables:
|
|
|
|
- **Common variables** like `$PASSWORD`, `$PASSWORDMAIL`, `$EMAIL`, `$USERNAME`, `$API_KEY`, `$TOKEN`, `$BASE_URL` show as info messages
|
|
- **Undefined variables** that are not commonly defined show as warnings
|
|
- Use the CLI with `--strict-variables` flag to treat undefined variables as errors during execution
|
|
|
|
## CLI Integration
|
|
|
|
The extension works with the PlayWrong CLI which supports:
|
|
- `--lint` - Run linter before execution
|
|
- `--strict` - Treat linter warnings as errors
|
|
- `--strict-variables` - Treat undefined variables as errors during execution |