Git Product home page Git Product logo

data-mocks's Introduction

data-mocks's People

Contributors

alcfeoh avatar benaud12 avatar dependabot[bot] avatar dinosys avatar fesales avatar grug avatar hentielouw avatar kirjai avatar krzysiekpiasecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

data-mocks's Issues

Matching http request are passing

Hi,

First of all i love the idea of the library. Great Job guys!!!. I wanted to include the the library in
my project, but i don't want to mock every request so i set MockConfig allowXHRPassthrough and allowFetchPassthrough to true. And the problem is every request
is passing even when there is matching route and when there is response then data-mocks
replace the response. Is that intended behaviour and can the requests be intercept when they match before sending(cause for example i want to mock and endpoint before is created)?

To Reproduce
Just create angular project the cli and add data-mock.
Set the allowXHRPassthrough and allowFetchPassthrough to true
Create some scenario(example:
{
url: /users/,
method: 'GET',
response: { some: 'good response' },
responseCode: 200
})
Make a http call to that scenario(example: ''http://localhost:3000/api/users')

Overhaul tests

The way we have the tests written for this isn't great. Once #49 and #48 have been solved, we can then probably rewrite all of the tests

All of the IE11 bugs

Describe the bug
This library doesn't work with IE11 at all. This is due to the right polyfills not existing.

To Reproduce

  1. Create a new project with data-mocks included
  2. Attempt to load up a page that uses data-mocks in IE11
  3. Observe a million console errors

Expected behavior
That this library works as intended with IE11

Additional context
There will need to be a fair few polyfills added for this :(

Support wildcard urls

Is your feature request related to a problem? Please describe.
I want to have a fallback for all URL's to they return a statuscode 404 unless they are specifiek in the scenario.

Describe the solution you'd like
An example on how to do this.

Describe alternatives you've considered
I've tried a wildcard regex:

const scenarios: Scenarios = {
    default: [
      {
        url: /(.*?)/,
        method: 'GET',
        response: {},
        responseCode: 404
      }
    ]
  }
injectMocks(scenarios);

Make mocks work with XHR

Currently, we only support mocking if users are using Fetch API. However, to really bring value to the users, we want to also provide the same mocking capabilities to those who use XmlHttpRequest

Document integration patterns

It'd be nice to have a section in the readme that describes how you could add this to your project if you were using either a React or Angular project.

Test data-mocks with ie11

There have been some issues with data-mocks and Android, which has led to the question of whether the library works properly in IE11. It hasn't been tested yet on IE11 so let's do that :)

Upgrade fetch-mock

The project is way behind with the fetch-mock version, which limits how we can test data-mocks and also means we are missing out on some general quality of life improvements

Allow to control fetch-mock 'warnOnFallback' API via MockConfig

Is your feature request related to a problem? Please describe.
Would like to disable fetch-mock warnings in console

Describe the solution you'd like

const mockConfig = {
 allowXHRPassthrough: true, 
 allowFetchPassthrough: true,
 warnOnFallback: false,
}

injectMocks(scenarios, 'default', mockConfig);

Describe alternatives you've considered

Probably this API can be set directly on FetchMock, which is not that convenient

import * as FetchMock from 'fetch-mock';
FetchMock.config.warnOnFallback = false;

multipart requests pass-through not working correctly

When I start my app using data-mocks for mocking e.g. my login service and I try to upload a file to my backend which is not mocked / passed-through, I got a 400 error telling me the request param is not been delivered to the backend. The request param is not available to Spring at all.
It seems like multipart file-streams are not being passed-through by data-mocks.

Downloading has same issue (which shouldnt come as. a surprise ;))

Using the same code without using data-mocks it works like a charm.

(angular) when compiling against es2018, a warning occurs during build

Describe the bug
Not sure if this goes here, but I figured I'd give it a shot and see what you think of the issue (since your documentation does mention Angular compatibility).

In the last version of Angular, the (default) compile-target is es2018.

Angular uses zone.js to hook into all asyncronous events (setTimeout, XMLHttpRequest, Promise) etc, but zone cannot do this with async or await because they are language constructs. With compile target es2018, async and await no longer get transpiled to Promise, and as a result a warning occurs during build, and change-detection in Angular may fail to be triggered when data changes.

One of the data-mocks dependencies (fetch-mock) uses native async and await, which no longer gets transpiled with es2018, and can therefor cause change-detection issues (as well as trigger a warning during build).

To Reproduce
Steps to reproduce the behavior:

  1. Create an Angular 11 project
  2. Implement data-mocks
  3. Do a build
  4. See warning in terminal

Expected behavior
No warning in terminal

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: 87.0.4280.141

Additional context
tsconfig:

{
  "compileOnSave": false,
  "compilerOptions": {
    "module": "es2020",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "target": "es2018",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

I realize this is not strictly speaking an issue in data-mocks, but would love a solution to this problem. Would it be possible for data-mocks to import from fetch-mocks/dist/es5/client-bundle instead? I think that would resolve the issue.

Use multiple scenarios at once

I frequently run into the need to use multiple scenarios at once and it would be amazing if it was possible to chain multiple scenarios in the url instead of having to tweak the mock-server file.

Add build pipeline

A circle pipeline to run tests/lint against PR's/master would be great

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.