New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

playwright-msw

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

playwright-msw - npm Package Compare versions

Comparing version

to
0.0.3

25

lib/server.js

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,6 +11,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { createMiddleware } from "@mswjs/http-middleware";
import { json } from "body-parser";
import express from "express";
import fetch from "node-fetch";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createServer = void 0;
const http_middleware_1 = require("@mswjs/http-middleware");
const body_parser_1 = require("body-parser");
const express_1 = __importDefault(require("express"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const rewriteBaseURL = (handler, baseUrl) => {

@@ -31,3 +37,3 @@ const currentMethod = handler.info.method;

.replace(`localhost:${webServerPort}`, `localhost:${workerServerPort}`);
return fetch(url, Object.assign(Object.assign({ method }, (["POST", "PATCH", "PUT"].includes(method)
return (0, node_fetch_1.default)(url, Object.assign(Object.assign({ method }, (["POST", "PATCH", "PUT"].includes(method)
? {

@@ -46,6 +52,6 @@ body: (_a = request.postData()) !== null && _a !== void 0 ? _a : "",

}
const app = express();
app.use(json());
const app = (0, express_1.default)();
app.use((0, body_parser_1.json)());
const transformedHandlers = [...customHandlers, ...handlers].map((handler) => rewriteBaseURL(handler, `http://localhost:${port}`));
app.use(createMiddleware(...transformedHandlers));
app.use((0, http_middleware_1.createMiddleware)(...transformedHandlers));
yield new Promise((resolve) => {

@@ -81,3 +87,3 @@ server = app.listen(port, () => {

};
export const createServer = ({ page, info, url, handlers, webServerPort, baseWorkerServerPort, }) => __awaiter(void 0, void 0, void 0, function* () {
const createServer = ({ page, info, url, handlers, webServerPort, baseWorkerServerPort, }) => __awaiter(void 0, void 0, void 0, function* () {
const workerServerPort = baseWorkerServerPort + info.parallelIndex;

@@ -107,1 +113,2 @@ const worker = createWorker(workerServerPort, ...handlers);

});
exports.createServer = createServer;
{
"name": "playwright-msw",
"version": "0.0.2",
"description": "A Mock Service Worker API for Playwright",
"version": "0.0.3",
"description": "A Mock Service Worker API for Playwright.",
"main": "lib/server.js",

@@ -6,0 +6,0 @@ "files": [