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

@tuchuang.space/mock-server

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tuchuang.space/mock-server

一个 server 模拟工具, 可配置响应, 获取某个请求是否接收到了

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

mock-server

一个 server 模拟工具, 可配置响应, 提供接口获取某个请求的详细数据

JavaScript Style Guide

Motivation

在 IE 11 中使用 selenium 测试 ctrl+v 粘贴功能的时候, 没有找到 spies 测试法来测试浏览器是否真正的发起了请求并且传入了合适的参数, 所以采用 mock 测试法, 这里的 mock-server 监听所有来临的请求并且提供接口查询该 mock-server 接收到的请求

Usage

const mockServer = require('mock-server')

describe('某个功能', () => {
  beforeAll(async () => {
    await mockServer.start()
  })
  afterAll(async () => {
    await mockServer.stop()
  })
  
  it('发起 /api/v1/image 请求, 并且带上图片数据', async () => {
    // arrange
    // act
    ctrl+vAction()
    
    // assert
    await new Promise((resolve) => setTimeout(resolve, 2000))
    const data = mockServer.search({ path: '/api/v1/image', method: 'POST' })
    expect(data[0].request.query).toEqual({ foo: 1, bar: 2 })
  })
})

MVP 版本

该项目处于 MVP(Minimum Viable Product) 开发阶段, 如果想了解 MVP 阶段会提供什么功能, 查看 MVP milestone

FAQs

Package last updated on 06 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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