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

msw

Package Overview
Dependencies
Maintainers
1
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msw - npm Package Compare versions

Comparing version 0.3.4 to 0.4.0

lib/handleIncomingRequest.d.ts

6

lib/composeMocks.d.ts

@@ -1,10 +0,8 @@

import { SchemaEntryGetter, SchemaEntry, SchemaEntryBody } from './handlers/createHandler';
import { RequestHandler } from './handlers/requestHandler';
export declare type Mask = RegExp | string;
export declare type MockingSchema = SchemaEntry<SchemaEntryBody[]>;
interface PublicAPI {
schema: MockingSchema;
start(serviceWorkerURL: string, options?: RegistrationOptions): void;
stop(): void;
}
export default function composeMocks(...handlers: SchemaEntryGetter[]): PublicAPI;
export declare const composeMocks: (...requestHandlers: RequestHandler[]) => PublicAPI;
export {};

@@ -48,3 +48,2 @@ import { ResponseTransformer } from './response';

}
declare const context: MockedContext;
export default context;
export declare const context: MockedContext;

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

/// <reference types="ts-toolbelt" />
import { Mask } from '../composeMocks';

@@ -26,3 +25,3 @@ import { MockedContext } from '../context';

}
declare const createHandler: import("Function/Curry").Curry<(method: RESTMethods, mask: Mask, resolver: ResponseResolver) => SchemaEntryGetter>;
declare const createHandler: import("ts-toolbelt/out/types/src/Function/Curry").Curry<(method: RESTMethods, mask: Mask, resolver: ResponseResolver) => SchemaEntryGetter>;
export default createHandler;

@@ -1,10 +0,11 @@

/// <reference types="ts-toolbelt" />
declare const _default: {
get: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
post: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
put: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
delete: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
patch: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
options: import("Function/Curry").Curry<(mask: import("../composeMocks").Mask, resolver: import("./createHandler").ResponseResolver) => import("./createHandler").SchemaEntryGetter>;
import { RequestHandler, ResponseResolver } from './requestHandler';
import { Mask } from '../composeMocks';
declare const restMethods: {
get: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
post: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
put: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
delete: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
patch: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
options: (mask: Mask, resolver: ResponseResolver) => RequestHandler;
};
export default _default;
export default restMethods;

@@ -1,4 +0,5 @@

export { default as composeMocks } from './composeMocks';
export { default as res } from './response';
export { default as context } from './context';
export { RequestHandler, RequestParams, ResponseResolver, RESTMethods, } from './handlers/requestHandler';
export { composeMocks } from './composeMocks';
export { response } from './response';
export { context } from './context';
export { default as rest } from './handlers/rest';

@@ -16,3 +16,2 @@ export interface MockedResponse {

export declare const defaultResponse: MockedResponse;
declare const response: ResponseComposition;
export default response;
export declare const response: ResponseComposition;

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

import { RequestParams } from '../handlers/createHandler';
import { RequestParams } from '../handlers/requestHandler';
export interface MatchPathOptions {

@@ -3,0 +3,0 @@ path?: RegExp | string;

{
"name": "msw",
"version": "0.3.4",
"version": "0.4.0",
"description": "Deviation-less client-side runtime API mocking using Service Workers.",

@@ -32,10 +32,10 @@ "main": "lib/index.js",

"path-to-regexp": "3.1.0",
"ramda": "0.26.1",
"yargs": "14.0.0"
"ramda": "^0.27.0",
"yargs": "^15.1.0"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@types/jest": "24.0.18",
"@types/ramda": "^0.26.21",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@types/jest": "^25.1.2",
"@types/ramda": "^0.26.41",
"awesome-typescript-loader": "^5.2.1",

@@ -50,7 +50,7 @@ "babel-loader": "8.0.6",

"regenerator-runtime": "0.13.3",
"ts-jest": "^25.0.0",
"ts-jest": "^25.2.0",
"typescript": "^3.7.5",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
}
}

@@ -181,5 +181,5 @@ <p align="center">

### `composeMocks(...MockDef): PublicAPI`
### `composeMocks(...args: RequestHandler[]): PublicAPI`
Composes given mocking definitions into a single schema.
Composes given mocking request handlers into a single schema.

@@ -199,2 +199,25 @@ #### Example

## Recipes
### Custom request handler
```js
import { composeMocks } from 'msw'
const hasHeader = (headerName, resolver) => ({
predicate(req) {
return req.headers[headerName]
},
resolver,
})
const { start } = composeMocks(
hasHeader('X-Mock-Response', (req, res, { json }) => {
return res(json({ mocked: true }))
}),
)
start()
```
## How does it work?

@@ -201,0 +224,0 @@

Sorry, the diff of this file is too big to display

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