testinha
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

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")

Package Sidebar

Install

npm i testinha

Weekly Downloads

4

Version

0.1.5

License

ISC

Unpacked Size

27.1 kB

Total Files

16

Last publish

Collaborators

  • alexandriasolar