3.2.1 • Published 28 days ago

apiunit v3.2.1

Weekly downloads
330
License
MIT
Repository
github
Last release
28 days ago

Apiunit

Apiunit is an awesome api unit testing framework! It allows creation of http requests and responses to create unit tests.

Commands

--input (-i): path to directory containing inputs (/requests is default) --diff (-d): path to directory containing expected output (/responses is default) --parameter (-p): path to the parameter .json file --prefix (-x): prefix of request(input) files to run --cmd (-c): command to be run between scenarios --scn (-s): The scenario or comma separated scenarios to run.

Parameter file example

Parameter files should be JSON format. Here is an example:

In this example we are running two scenarios named scn1 and scn2 on the folder(group) of "assets/testSuite". In each scenario, the PARAM1 and PARAM2 variables will be replaced with the values in the scenarios.

Request / Response file examples

Request files should end with .req or .msg extension, and response files should end with .resp extension. Every request should have a matching response with the same name minus extension. Response files can also use regular expressions to match expected responses.

Request files also allow the parameter APIUNIT-RETRY which can be set to any value, but default is 15000ms. APIUNIT-RETRY will retry the request until it matches the associated response or fails within the given timeframe.

Response files also allow the header apiunit-ignore-array-order which use a JSONPath expression to allow arrays to be unordered. Use path1,path2 where the value is a comma separated list of expressions to allow. Any array can be represented with $.., or a more explicit path can be specified. For example, targeting values in only key1 in the following json structure would look like data[*].key1.values.

{
   "data": [
      {
         "key1": {
            "values": [1,2,3]
         },
         "key2": {
            "values": [4,5,6]
         }
      },
      {
         "key1": {
            "values": [1,2,3]
         },
         "key2": {
            "values": [4,5,6]
         }
      }
   ]
}

Example request:

Example response:

Example Execution

To run a simple apiunit task just run the command "node ../node_modules/.bin/apiunit -i specs/requests -d specs/responses -p parameters.json -c \"npm run add-some-data-or-something\"".

3.2.1

28 days ago

3.2.0

29 days ago

3.1.0

10 months ago

2.8.0

12 months ago

2.7.0

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

3.0.0

2 years ago

2.4.2

2 years ago

2.5.0

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.3.5

2 years ago

2.3.4

3 years ago

2.3.3

3 years ago

2.2.0

3 years ago

2.3.0

3 years ago

2.3.2

3 years ago

2.3.1

3 years ago

2.1.16

3 years ago

2.1.15

4 years ago

2.1.14

4 years ago

2.1.13

4 years ago

2.1.12

4 years ago

2.1.10

4 years ago

2.1.11

4 years ago

2.1.9

4 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

6 years ago

2.0.14

6 years ago

2.0.13

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago