Code Monkey home page Code Monkey logo

mockyeah's Introduction

mockyeah's People

Contributors

andersdjohnson avatar fuller avatar mprokopowicz avatar ryanricard avatar smably avatar tcrowe avatar therynamo 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

Watchers

 avatar  avatar  avatar  avatar

mockyeah's Issues

feat: support alias `url` of `path` in match for proxy

When we're defining mocks in the proxy use case (e.g., #106), it would feel more natural to use url rather than path, so we should support an alias key.

Instead of:

mockyeah.get({
  path: 'http://localhost:8888/foo?ok=yes'
}, { text: 'bar' })

It'd be nice to say:

mockyeah.get({
  url: 'http://localhost:8888/foo?ok=yes'
}, { text: 'bar' })

Deactivate log in config

When using mockyeah directly in tests the test runner stdout will always contain the log messages, e.g.

Scenario: Make something after logging in
[mockyeah][REQUEST][GET] /wp-json/wp/v2/something (1ms)
[mockyeah][REQUEST][POST] /api/users/401/session (1ms)
      โœ“ Given: I logged in (384ms)

While this is very helpful during test development, for test reporting it introduces noise and makes the test results hard to read.

We'd like to write test code like

var mockyeah = require('mockyeah');
mockyeah.log = false;
mockyeah.get(/wp-json\/wp\/v2\/something/, { json: '{ "info":"something"}'});

and in case we have problems while implementing a test we simply change to mockyeah.log = true;

Defining mocks for proxy should not require leading slash

So that it feels more natural to mock some requests when using the proxy...

Instead of:

mockyeah.get('/http://localhost:8888/foo?ok=yes', { text: 'bar' })

It'd be nice just only have to do:

mockyeah.get('http://localhost:8888/foo?ok=yes', { text: 'bar' })

with no leading slash.

Support fixture transform function for mock services

Sometimes it's useful to start with a base fixture file but transform it slightly to be relevant to the current test. Rather than requiring us to manually read & parse the file then use json, why not offer a fixture transform function option to be used optionally alongside existing fixture option?

Relates to #403.

feat: record only some URLs (e.g., by regex)

Snapshot recording could be noisy and result in lots of fixtures that the user doesn't want or need. We could support starting a snapshot recording session that is scoped to only some URLs, e.g., by accepting a string the URL should contain, a glob pattern, or regular expression. This could be part of the CLI as well.

Create documentation site?

The repo wiki is not conducive to collaboration. Thoughts on moving the documentation to a github pages site?

Support https

Support starting server in HTTPS mode, to avoid CORS issues from HTTPS browser applications.

Review package.json keywords

Why are more people not finding mockyeah? Are there keywords that should be added? How do the keywords for related projects compare?

feat(fetch): support exact mock matches for objects

Add a feature to force an exact match instead of default partial matching on query parameters, request body, HTTP headers, and/or cookies, so that a mock won't match if it includes any unspecified additional or extraneous values. There may also be an integration with the expectation features here too.

Something like:

mockyeah.get({ params: { only: '1' }, exact: true })

Which I think should default to just params and body exact matches, not headers or cookies.

Then we can specifically target headers, cookies, etc., with:

mockyeah.get({
  params: { only: '1' },
  body: { only: '1' },
  headers: { only: '1' },
  cookies: { only: '1' },
  exact: {
    params: true,
    body: true,
    headers: true,
    cookies: true
  }
})

We may want to exempt the Cookie header from the headers exact matching, perhaps only when cookies is also present.

Update ESLint

Project is currently bound to ESLint ^1.10.3, latest is 3.9.1. There are breaking changes between versions, so updating will be more involved than binding latest in package.json.

Suggestion: add request journal

It's just a suggestions to add features to this great library.

In hermetic ui testing (as defined by google) we mock out backend, considering the front end a system by itself. System level testing would then correspond to e.g. clicking, responding with mockyeah, but also verifying the sent request as is possible for example in wiremock.

Feature: request verification
As a front developer I want to verify the requests sent by my application in order to have system test coverage
Scenario: my application composes a complex request
Given I automate my UI test with selenium
And I choose various options at the UI for a complex request
And I mock out back end with mockyeah (from my selenium / protractor code)
When I confirm my changes
Then I can obtain the sent request from mockyeah
And verify the request is as I expect

Typically, it's important to

  • configure if request journal is active or not in order to avoid memory problems in soak testing
  • reset the request journal to only check over requests of a certain test run

Support error message in responses with status != 500

By test example
mockyeah.get('/wondrous', { status: 422 }); will return a response with code 422.
However, when I set
mockyeah.get('/wondrous', { status: 422, message: "MYERRORCODE" }); mockyeah won't start.
Error message:
Error: Response option(s) invalid. Options must include one of the following: fixture, filePath, html, json, text, status, headers, raw, latency, type
at validateResponse (/home/sebastian/legolas/frontend/node_modules/mockyeah/app/lib/RouteResolver.js:42:11)

Our backend will return 422 but with several error codes in the field message. Therefore for us at least, it is necessary to be able to define this field

Review mockyeah-cli documentation

mockyeah-cli's documentation is very terse, which might be ok; nevertheless, we should brainstorm improvements that may be helpful to new users.

Write v1 documentation

  • Document new param matching functionality
  • Document proxy middleware behavior
  • Consider creating Gitbook documentation site to house v1 and pre v1 documentation

feat: expect params alias as query

Since we use query in matches (due to Express path segments called parameters), we should support the same language with the expect API.

Add middleware test

@therynamo, are you interested in writing a test to assert the availability of the middleware method you exposed? I am doing some heavy refactoring and I want to ensure I don't break your implementation.

Let overwrite behaviour during test run / enable default setups

1.) I have a default test setup with .get(/someRoute/, {json:someResponse1})
2.) alternative test starts
3.) alternative test sets .get(/someRoute/, {json:someResponse2})
4.) test requests /someRoute/
==> mockyeah returns someResponse1
Expected => mockyeah returns someResponse2

Note:
I don't want to run a mockyeah.reset as I have a full workflow I want to test

Make compatible with older versions of Node

mockyeah's use of latest ECMAScript features make incompatible with older versions of node. We should consider increasing its compatibility so more people can benefit from its use.

Done when:

  • A minimum Node version is determined.
  • CI automation is implemented to assert compatibility with multiple Node versions (e.g. https://github.com/victorbjelkholm/autochecker)
  • mockyeah is updated to support the lowest agreed upon version of Node.

Review mockyeah documentation

mockyeah's documentation should be clear and succinct. It needs to be easy enough to consume that new users can easily understand its use-case, while including the details needed to understands its complete api.

Eliminate unnecessary use of Gulp

Gulp is not needed to execute linting and testing tasks. Linting and testing framework binaries can be executed from development dependencies via NPM Scripts.

feat(server)!: review mockyeah dot file implementation

Review how mockyeah finds its dot file (i.e. .mockyeah). Projects can have multiple dot files (e.g. one in project root for development and one in test directory for test configuration), ensure mockyeah is finding the correct file depending on main module directory context.

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.