0.1.5 • Published 2 years ago

testinha v0.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Testinha

npm version install size npm downloads

Routes tester for node.js

Created by: Alexandria


Installing

Using npm:

npm install testinha

Using npm as dev dependence:

npm install testinha --save-dev

Using yarn:

yarn add testinha

Using yarn as dev dependence:

yarn add testinha -D

Dependencies

How to use it

  • Starting an instance of Testinha

    const test = Testinha("https://google.com", 80);
  • Changing the base url

    test.changeBaseUrl("https://google.com");
  • Changing the port

    test.changePort("80");
  • Testing a route

    test.testOne({
      answer: { error: "No data provided" },
      url: "test",
      method: "GET",
      comparation: "EQUAL",
      params: { data: "no data" }
    }).then(res => console.log(res))
  • Testing many routes

    test.test([
      {
        answer: { error: "No data provided" },
        url: "test",
        method: "GET",
        comparation: "EQUAL",
        params: { data: "no data" }
      },
      {
        answer: "",
        url: "login",
        method: "POST",
        comparation: "TYPE",
        body: {
          email: "me@gmail.com",
          password: "123",
        },
      },
      {
        answer: {
          user: { name: "string", email: "string", age: "number" },
          access: "string"
        },
        url: "user",
        method: "GET",
        comparation: "INTERFACE",
        params: { email: "me@gmail.com" }
      }
    ])

Params explanation

  • baseURL:

    • The consistent part of the web address you want to test
  • port:

    • The port of the web address you want to test
  • answer:

    • The expected answer for the route
  • url:

    • The route you want to test
  • method:

    • The method used for the route
    • Accepted methods: GET, POST, PUT, DELETE
    • Defaults to: GET
  • comparation:

    • The type of comparation between the expected answer and the received answer
    • Accepted comparations: EQUAL, TYPE, INTERFACE
    • Defaults to: EQUAL
    • EQUAL: compares if the answers are exact the same
    • TYPE: compares if the answers are the same type (objects are considered the same no matter theirs keys)
    • INTERFACE: compares if the answer received has the exact same type as the expected answer defined (each objects keys are compared, unless the expected answer is "object")
0.1.4

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago