Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BedrockStreaming/superagent-mock
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.5.0
Choose a base ref
...
head repository: BedrockStreaming/superagent-mock
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 4,645 additions and 2,839 deletions.
  1. +0 −3 .babelrc
  2. +1 −1 .eslintrc
  3. +25 −0 .github/workflows/node.js.yml
  4. +19 −0 .github/workflows/publish.yml
  5. +1 −2 .gitignore
  6. +0 −1 .npmignore
  7. +6 −0 .prettierrc
  8. +0 −7 .travis.yml
  9. +16 −10 README.md
  10. +11 −0 babel.config.js
  11. +19 −16 package.json
  12. +110 −44 src/superagent-mock.js
  13. +1 −1 tests/client.spec.js
  14. +32 −32 tests/support/config.js
  15. +294 −197 tests/support/expectations.js
  16. +4,110 −2,525 yarn.lock
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
"no-multi-str": 0
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": "latest",
"sourceType": "module"
}
}
25 changes: 25 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continous Integration

on:
push:
branches: [master]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
superagent-version: [8.0.9]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- run: yarn install
- run: yarn add superagent@~${{ matrix.superagent-version }} && yarn ci
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish package

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- run: yarn install
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
*.log
lib
es
.idea
.idea
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.*
yarn.lock
tests
!es/
!lib/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"printWidth": 120,
"trailingComma": "all",
"bracketSpacing": false
}
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
![](https://img.shields.io/badge/License-MIT-00CCFF.svg?style=flat-square)
![](https://img.shields.io/badge/superagent--mock-JS-FF0066.svg?style=flat-square)
[![NPM Downloads](http://img.shields.io/npm/dm/superagent-mock.svg?style=flat-square)](https://www.npmjs.org/package/superagent-mock)
[![Build Status](http://img.shields.io/travis/M6Web/superagent-mock.svg?style=flat-square)](https://travis-ci.org/M6Web/superagent-mock)
![npm](https://img.shields.io/npm/v/superagent-mock)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/superagent-mock)
![npm](https://img.shields.io/npm/dy/superagent-mock)
![GitHub last commit](https://img.shields.io/github/last-commit/M6web/superagent-mock)
![NPM](https://img.shields.io/npm/l/superagent-mock)
[![NPM Downloads](http://img.shields.io/npm/dm/superagent-mock.svg)](https://www.npmjs.org/package/superagent-mock)
[![Continous Integration](https://github.com/M6Web/superagent-mock/actions/workflows/node.js.yml/badge.svg)](https://github.com/M6Web/superagent-mock/actions/workflows/node.js.yml)

<p align="center">
<b><a href="#installation">Installation</a></b>
@@ -10,8 +13,6 @@
|
<b><a href="#supported-methods">Supported Methods</a></b>
|
<b><a href="#tests">Tests</a></b>
|
<b><a href="#credits">Credits</a></b>
|
<b><a href="#license">License</a></b>
@@ -21,14 +22,19 @@

[superagent](https://github.com/visionmedia/superagent) plugin allowing to simulate HTTP calls by returning data fixtures based on the requested URL.

See [this post](http://tech.m6web.fr/how-did-we-mock-the-backend-developers.html) to know why we use superagent-mock at M6Web.
See [this post](https://tech.bedrockstreaming.com//how-did-we-mock-the-backend-developers.html) to know why we use superagent-mock at Bedrock Streaming.

## Installation

Install with [npm](http://npmjs.org/): `npm install superagent-mock`

Install with [yarn](https://yarnpkg.com/): `yarn add superagent-mock`

## Requirements

node >= 8.0
superagent >= ^3.6.0

## Usage

First, you have to define the URLs to mock in a configuration file:
@@ -160,7 +166,7 @@ module.exports = [
*/
post: function (match, data) {
return {
code: 201
       status: 201
};
}
},
@@ -231,8 +237,8 @@ To build code: `yarn build`.

## Credits

Developped by the [Cytron Team](http://cytron.fr/) of [M6 Web](http://tech.m6web.fr/).
Tested with [nodeunit](https://github.com/caolan/nodeunit).
Developped by the Cytron Team of [Bedrock Streaming](https://tech.bedrockstreaming.com/).
Tested with [Jest](https://jestjs.io/).

## License

11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: '3',
},
],
],
};
35 changes: 19 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
{
"name": "superagent-mock",
"description": "superagent plugin allowing to simulate HTTP calls by returning data fixtures based on the requested URL.",
"version": "3.5.0",
"version": "5.0.1",
"keywords": [
"superagent",
"mock",
"isomorphic"
],
"bugs": "https://github.com/M6Web/superagent-mock/issues",
"license": "MIT",
"main": "./lib/superagent-mock.js",
"main": "lib/superagent-mock.js",
"module": "es/superagent-mock.js",
"repository": {
"type": "git",
"url": "https://github.com/M6Web/superagent-mock"
"url": "git+https://github.com/M6Web/superagent-mock.git"
},
"engines": {
"node": ">=16.0.0"
},
"peerDependencies": {
"superagent": "^3.5.2"
"superagent": ">=8.0.9"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.3",
"babel-preset-env": "^1.4.0",
"cross-env": "^5.0.0",
"eslint": "^3.19.0",
"jest": "20.0.3",
"rimraf": "^2.6.1",
"superagent": "^3.5.2"
"@babel/cli": "^7.7.4",
"@babel/preset-env": "^7.13.10",
"core-js": "^3.4.7",
"cross-env": "^7.0.3",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"rimraf": "^3.0.0",
"superagent": "8.0.9"
},
"scripts": {
"ci": "yarn clean && yarn lint && yarn build && yarn test",
"clean": "rimraf lib es",
"test": "jest tests",
"lint": "eslint src tests",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build": "yarn build:commonjs && yarn build:es",
"prepublish": "yarn run clean && yarn lint && yarn build"
"build": "cross-env babel src --out-dir lib",
"prepublishOnly": "yarn ci"
}
}
Loading