Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davekiss/json-to-playwright
https://github.com/davekiss/json-to-playwright
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/davekiss/json-to-playwright
- Owner: davekiss
- Created: 2024-01-07T20:05:48.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-01-14T12:30:49.000Z (10 months ago)
- Last Synced: 2024-03-14T22:50:19.542Z (8 months ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# json-to-playwright
## How to use
```
// JSON input (assuming this is read from a file or other sources)
const jsonInput = `
{
"title": "Recording 12/30/2023 at 8:49:56 AM",
"steps": [
{
"type": "setViewport",
"width": 723,
"height": 993
},
{
"type": "navigate",
"url": "https://vuoriclothing.com/"
},
...
]
}
`;// Convert the JSON string to an object
const data: JsonInput = JSON.parse(jsonInput);// Generate the script
const playwrightScript = generatePlaywrightScript(data);// Write to a file (optional)
writeFile('playwrightTest.ts', playwrightScript, (err) => {
if (err) throw err;
console.log('The file has been saved!');
});// Or you can directly log the script
console.log(playwrightScript);
```## Generating actions only
To skip the `test` wrapper and `expect` assertions, you can output actions only by passing a second config object:
```js
const playwrightScript = generatePlaywrightScript(data, { actionsOnly: true });
```