pw2art – Babel plugin for Playwright to Artillery transpilation
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
pw2art is a Babel plugin that transpiles standard Playwright test syntax into syntax compatible with the Artillery Playwright engine. Version 1.0.0 is the initial stable release. It automates the conversion of Playwright tests for use with Artillery's load testing engine, reducing manual rewriting. Key differentiator: eliminates the tedious process of adapting Playwright scripts for Artillery, enabling reuse of existing test suites for performance testing. Release cadence is not yet established.
Common errors
error ReferenceError: require is not defined ↓
cause Using CommonJS require on ESM-only package.
fix
Use import syntax or change to ES module.
error TypeError: transform is not a function ↓
cause Incorrect import (default vs named).
fix
Use import { transform } from 'pw2art'.
error Error: Not a valid Babel plugin ↓
cause Trying to use pw2art directly as Babel plugin without wrapper.
fix
Use babelPluginPw2art export or configure via .babelrc with require('pw2art').babelPluginPw2art.
Warnings
breaking Version 1.0.0 only supports a subset of Playwright API. ↓
fix Ensure your Playwright test uses only supported methods (page.goto, page.click, etc.). Check documentation for full list.
deprecated The transform function may change in future releases. ↓
fix Pin to specific version if using programmatic API.
gotcha Transpiled code may require manual adjustments for complex selectors or assertions. ↓
fix Review output and modify Artillery YAML configuration as needed.
Install
npm install pw2art yarn add pw2art pnpm add pw2art Imports
- default wrong
const pw2art = require('pw2art')correctimport pw2art from 'pw2art' - transform wrong
const { transform } = require('pw2art')correctimport { transform } from 'pw2art' - babelPluginPw2art wrong
const { babelPluginPw2art } = require('pw2art')correctimport { babelPluginPw2art } from 'pw2art'
Quickstart
import pw2art from 'pw2art';
import { transform } from 'pw2art';
// Example Playwright test code
const playwrightCode = `
import { test, expect } from '@playwright/test';
test('example test', async ({ page }) => {
await page.goto('https://example.com');
const title = await page.title();
expect(title).toBe('Example Domain');
});
`;
// Transform to Artillery syntax
const result = transform(playwrightCode, { imports: false });
console.log(result.code);