Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

@nightwatch/chrome-recorder

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nightwatch/chrome-recorder - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

1

dist/main.d.ts
import { Schema } from '@puppeteer/replay';
export declare function parseRecordingContent(recordingContent: string): Schema.UserFlow;
export declare function transformParsedRecording(parsedRecording: Schema.UserFlow): Promise<string>;
export declare function formatParsedRecordingContent(transformedRecordingContent: string): string;
export declare function nightwatchStringifyChromeRecording(recording: string): Promise<Promise<string> | undefined>;
import { parse, stringify } from '@puppeteer/replay';
import { NightwatchStringifyExtension } from './nightwatchStringifyExtension.js';
import prettier from 'prettier';
export function parseRecordingContent(recordingContent) {

@@ -12,9 +11,2 @@ return parse(JSON.parse(recordingContent));

}
export function formatParsedRecordingContent(transformedRecordingContent) {
return prettier.format(transformedRecordingContent, {
semi: true,
singleQuote: true,
parser: 'babel',
});
}
export async function nightwatchStringifyChromeRecording(recording) {

@@ -26,3 +18,3 @@ if (recording.length === 0) {

const parsedRecording = parseRecordingContent(recording);
return formatParsedRecordingContent(await transformParsedRecording(parsedRecording));
return await transformParsedRecording(parsedRecording);
}

50

dist/nightwatchStringifyExtension.js

@@ -6,3 +6,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {

};
var _NightwatchStringifyExtension_instances, _NightwatchStringifyExtension_formatAsJSLiteral, _NightwatchStringifyExtension_appendStepType, _NightwatchStringifyExtension_appendNavigateStep, _NightwatchStringifyExtension_appendViewportStep, _NightwatchStringifyExtension_appendClickStep, _NightwatchStringifyExtension_appendChangeStep, _NightwatchStringifyExtension_appendKeyDownStep, _NightwatchStringifyExtension_appendKeyUpStep, _NightwatchStringifyExtension_appendScrollStep, _NightwatchStringifyExtension_appendDoubleClickStep, _NightwatchStringifyExtension_appendEmulateNetworkConditionsStep, _NightwatchStringifyExtension_appendWaitForElementStep;
var _NightwatchStringifyExtension_instances, _NightwatchStringifyExtension_formatAsJSLiteral, _NightwatchStringifyExtension_appendStepType, _NightwatchStringifyExtension_appendNavigateStep, _NightwatchStringifyExtension_appendViewportStep, _NightwatchStringifyExtension_appendClickStep, _NightwatchStringifyExtension_appendChangeStep, _NightwatchStringifyExtension_appendKeyDownStep, _NightwatchStringifyExtension_appendKeyUpStep, _NightwatchStringifyExtension_appendScrollStep, _NightwatchStringifyExtension_appendDoubleClickStep, _NightwatchStringifyExtension_appendEmulateNetworkConditionsStep, _NightwatchStringifyExtension_appendWaitForElementStep, _NightwatchStringifyExtension_appendEndStep;
import { PuppeteerStringifyExtension, } from '@puppeteer/replay';

@@ -22,2 +22,3 @@ import { SupportedKeys } from './types.js';

async afterAllSteps(out) {
__classPrivateFieldGet(this, _NightwatchStringifyExtension_instances, "m", _NightwatchStringifyExtension_appendEndStep).call(this, out);
out.appendLine('});').endBlock();

@@ -81,7 +82,5 @@ out.appendLine('});');

}, _NightwatchStringifyExtension_appendNavigateStep = function _NightwatchStringifyExtension_appendNavigateStep(out, step) {
out.appendLine(`browser.navigateTo(${__classPrivateFieldGet(this, _NightwatchStringifyExtension_instances, "m", _NightwatchStringifyExtension_formatAsJSLiteral).call(this, step.url)});`);
out.appendLine(' ');
out.appendLine(`.navigateTo(${__classPrivateFieldGet(this, _NightwatchStringifyExtension_instances, "m", _NightwatchStringifyExtension_formatAsJSLiteral).call(this, step.url)})`);
}, _NightwatchStringifyExtension_appendViewportStep = function _NightwatchStringifyExtension_appendViewportStep(out, step) {
out.appendLine(`browser.windowRect({width: ${step.width}, height: ${step.height}});`);
out.appendLine(' ');
out.appendLine(`browser.windowRect({width: ${step.width}, height: ${step.height}})`);
}, _NightwatchStringifyExtension_appendClickStep = function _NightwatchStringifyExtension_appendClickStep(out, step, flow) {

@@ -92,4 +91,4 @@ const domSelector = this.getSelector(step.selectors, flow);

hasRightButton
? out.appendLine(`browser.rightClick(${domSelector});`)
: out.appendLine(`browser.click(${domSelector});`);
? out.appendLine(`.rightClick(${domSelector})`)
: out.appendLine(`.click(${domSelector})`);
}

@@ -102,3 +101,3 @@ else {

if (domSelector) {
out.appendLine(`browser.setValue(${domSelector}, ${__classPrivateFieldGet(this, _NightwatchStringifyExtension_instances, "m", _NightwatchStringifyExtension_formatAsJSLiteral).call(this, step.value)});`);
out.appendLine(`.setValue(${domSelector}, ${__classPrivateFieldGet(this, _NightwatchStringifyExtension_instances, "m", _NightwatchStringifyExtension_formatAsJSLiteral).call(this, step.value)})`);
}

@@ -109,11 +108,8 @@ }, _NightwatchStringifyExtension_appendKeyDownStep = function _NightwatchStringifyExtension_appendKeyDownStep(out, step) {

const keyValue = SupportedKeys[pressedKey];
out.appendLine(`
browser.perform(function() {
out.appendLine(`.perform(function() {
const actions = this.actions({async: true});
return actions
.keyDown(Keys.${keyValue});
});
`);
out.appendLine(' ');
.keyDown(this.Keys.${keyValue});
})`);
}

@@ -124,11 +120,8 @@ }, _NightwatchStringifyExtension_appendKeyUpStep = function _NightwatchStringifyExtension_appendKeyUpStep(out, step) {

const keyValue = SupportedKeys[pressedKey];
out.appendLine(`
browser.perform(function() {
out.appendLine(`.perform(function() {
const actions = this.actions({async: true});
return actions
.keyUp(Keys.${keyValue});
});
`);
out.appendLine(' ');
.keyUp(this.Keys.${keyValue});
})`);
}

@@ -138,12 +131,11 @@ }, _NightwatchStringifyExtension_appendScrollStep = function _NightwatchStringifyExtension_appendScrollStep(out, step, flow) {

const domSelector = this.getSelector(step.selectors, flow);
out.appendLine(`browser.moveToElement(${domSelector}, 0, 0);`);
out.appendLine(`.moveToElement(${domSelector}, 0, 0)`);
}
else {
out.appendLine(`browser.execute('scrollTo(${step.x}, ${step.y})');`);
out.appendLine(`.execute('scrollTo(${step.x}, ${step.y})')`);
}
out.appendLine(' ');
}, _NightwatchStringifyExtension_appendDoubleClickStep = function _NightwatchStringifyExtension_appendDoubleClickStep(out, step, flow) {
const domSelector = this.getSelector(step.selectors, flow);
if (domSelector) {
out.appendLine(`browser.doubleClick(${domSelector});`);
out.appendLine(`.doubleClick(${domSelector})`);
}

@@ -155,3 +147,3 @@ else {

out.appendLine(`
browser.setNetworkConditions({
.setNetworkConditions({
offline: false,

@@ -161,3 +153,3 @@ latency: ${step.latency},

upload_throughput: ${step.upload}
});`);
})`);
}, _NightwatchStringifyExtension_appendWaitForElementStep = function _NightwatchStringifyExtension_appendWaitForElementStep(out, step, flow) {

@@ -167,7 +159,7 @@ const domSelector = this.getSelector(step.selectors, flow);

out.appendLine(`
browser.waitForElementVisible(${domSelector}, ${step.timeout}, function(result) {
.waitForElementVisible(${domSelector}, ${step.timeout}, function(result) {
if (result.value) {
browser.expect.elements(${domSelector}).count.to.equal(${step.count});
}
});
})
`);

@@ -178,2 +170,4 @@ }

}
}, _NightwatchStringifyExtension_appendEndStep = function _NightwatchStringifyExtension_appendEndStep(out) {
out.appendLine(`.end();`);
};
import { Flags } from './types.js';
export declare function formatParsedRecordingContent(transformedRecordingContent: string): string;
export declare function runTransformsOnChromeRecording({ files, outputPath, flags, }: {

@@ -3,0 +4,0 @@ files: string[];

@@ -5,3 +5,11 @@ import chalk from 'chalk';

import { nightwatchStringifyChromeRecording } from './main.js';
import { format } from 'prettier';
const __dirname = path.resolve(path.dirname('.'));
export function formatParsedRecordingContent(transformedRecordingContent) {
return format(transformedRecordingContent, {
semi: true,
singleQuote: true,
parser: 'babel',
});
}
export function runTransformsOnChromeRecording({ files, outputPath, flags, }) {

@@ -17,6 +25,7 @@ const outputFolder = path.join(__dirname, outputPath);

}
const formattedStringifiedFile = formatParsedRecordingContent(stringifiedFile);
const fileName = file.split('/').pop();
const testName = fileName ? fileName.replace('.json', '') : undefined;
if (dry) {
console.log(stringifiedFile);
console.log(formattedStringifiedFile);
}

@@ -28,3 +37,3 @@ else if (!testName) {

exportFileToFolder({
stringifiedFile,
stringifiedFile: formattedStringifiedFile,
testName,

@@ -31,0 +40,0 @@ outputPath,

{
"name": "@nightwatch/chrome-recorder",
"version": "0.1.0",
"version": "0.1.1",
"description": "Generate Nightwatch Tests from Google Chrome DevTools Recordings",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -10,8 +10,8 @@ # Nightwatch Chrome Recorder

๐Ÿ’ƒ Users can also use a dry run to see the interim output of the recordings
๐Ÿ‘จโ€๐Ÿ’ป Programmatic API which users can use in their own project to create plugins or custom scripts.
๐Ÿ‘จโ€๐Ÿ’ป Programmatic API which users can use in their own project to create plugins or custom scripts.
## ๐Ÿ“น Demo
![Nightwatch Chrome Recorder Demo](.github/assets/demo.gif)
## ๐Ÿ— Installation

@@ -62,7 +62,4 @@

```typescript
import {
nightwatchStringifyChromeRecording,
formatParsedRecordingContent,
} from '@nightwatch/chrome-recorder';
```javascript
import { nightwatchStringifyChromeRecording } from '@nightwatch/chrome-recorder';

@@ -88,3 +85,3 @@ const recordingContent = {

console.log(formatParsedRecordingContent(stringifiedContent));
console.log(stringifiedContent);
// Console Log output

@@ -91,0 +88,0 @@ //

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc