Giter Club home page Giter Club logo

url-decorator's Introduction

url-decorator

npm Build Status Coverage Status

Common plugin for:

which is intended to change test urls in runtime.

You can read more about gemini plugins here and hermione plugins here.

Installation

npm install url-decorator

Usage

Configuration

  • enabled (optional) Boolean โ€“ enable/disable the plugin; by default plugin is enabled
  • url (optional) Object - the list of url parameters, which will be added in each test url
    • query (optional) Array - the list of query parameters
      • queryParam (optional) Object - query parameter object with fields:
        • name (optional) String - name of query parameter
        • value (optional) String|Number|Array - value of query parameter
        • mode (optional) String - parameters joining strategy. Can be concat or override. By default is concat.
        • browsers (optional) String|RegExp|Array<String|RegExp> - browsers condition. Query parameter will be applied only for configured browsers.

Gemini usage

Add plugin to your gemini config file:

system:
  plugins:
    url-decorator/gemini: true

To pass additional url parameters you can use environment variables, which should start with GEMINI_URL_ or specify them in the gemini config file.

For example, you have the following test url: http://localhost/test/?name=bilbo and you want to add query parameter via environment variable:

GEMINI_URL_QUERY_TEXT=ololo gemini test

After that your test url will be changed to: http://localhost/test/?name=bilbo&text=ololo.

The same thing you can do using gemini config file:

url-decorator/gemini:
  url:
    query:
      - name: text
        value: ololo
    # or
        text: ololo

Note: environment variables have higher priority than config values.

Hermione usage

Add plugin to your hermione config file:

module.exports = {
    // ...

    plugins: {
        'url-decorator/hermione': true
    },

    // ...
};

To pass additional url parameters you can use environment variables, which should start with HERMIONE_URL_ or specify them in the hermione config file.

For example, you have the following test url: http://localhost/test/?name=hermione and you want to add query parameter via environment variable:

HERMIONE_URL_QUERY_TEXT=ololo hermione

After that your test url will be changed to: http://localhost/test/?name=hermione&text=ololo.

The same thing you can do using hermione config file:

'url-decorator/hermione': {
    url: {
        query: [
            {
                name: 'text'
                value: 'ololo'
            }
        ]
        // or
        query: {
            text: 'ololo'
        }
    }
}

Note: environment variables have higher priority than config values.

Concatenation of url parameters

In previous example you have seen how add url parameters. Now we look how to concat and override url parameters.

Suppose, you want to add query parameter name which is already presented in your test url: http://localhost/test/?name=bilbo and you don't want to override it:

url-decorator/gemini:
  url:
    query:
      - name: 'name'
        value: 'torin'
        mode: 'concat'
      # or
      - name: 'name'
        value: torin

The result url will look like: http://localhost/test/?name=bilbo&name=torin. How you understand, the result will be the same if concat would be any value except false.

Moreover for previous test url you can specify a set of values for one query parameter:

url-decorator/gemini:
  url:
    query:
      - name: 'name'
        value:
          - torin
          - gloin

The result url will look like: http://localhost/test/?name=bilbo&name=torin&name=gloin

If you want to override value of name query parameter:

url-decorator/gemini:
  url:
    query:
      - name: 'name'
        value: torin
        mode: 'override'

As a result url will look like: http://localhost/test/?name=torin.

You can do the same thing via environment variables. In this case concat value will be used from config to the same url parameter:

GEMINI_URL_QUERY_NAME=gloin gemini test

The result url will look like: http://localhost/test/?name=gloin

Browser conditions

url-decorator gives the opportunity to set each of query parameters only for specified browser(s).

Browsers can be:

  • single browser id string
  • array of multiple browser ids
  • browser mask (regular expression)
  • array of browser masks

Examples:

url-decorator/gemini:
  url:
    query:
      - name: 'name'
        value: torin
        browsers: firefox
url-decorator/gemini:
  url:
    query:
      - name: 'name'
        value: torin
        browsers:
         - firefox
         - chrome
url-decorator/gemini: {
    url: {
        query: [
            {
                name: 'name',
                value: 'torin',
                browsers: /ie-\d+/  //ie-8, ie-9, ie-10, ...
            }
        ]
    }
}
url-decorator/gemini: {
    url: {
        query: [
            {
                name: 'name',
                value: 'torin',
                browsers: [/ie-\d+/, 'firefox']
            }
        ]
    }
}

url-decorator's People

Contributors

dudagod avatar j0tunn avatar rostik404 avatar sipayrt avatar tormozz48 avatar

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.