npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@reportfy/tester

v1.2.9

Published

Lib para teste de integração usando serviço do reportfy

Downloads

137

Readme

@reportfy/tester

npm version install size npm downloads

reportfy

Tester de integração para clientes que utilizam node.js.

Sobre reportfy: clique aqui

Sobre a tester.

instalação

Usando npm:

$ npm install @reportfy/tester

Usando yarn:

$ yarn add @reportfy/tester

Configuração

Para configuração é necessário acessar o sistema da reporfy e criar seus casos de teste, com isso terá o token para integração do sdk.

Após a instalação do sdk no package.json será criado um script de inicialização no projeto.

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "tester": "npx reportfy -k sua_chave_aqui' -ac 'access_key', -se 'secret_key' -s index.js -t express"
  },
  "dependencies": {
    "@reportfy/tester": "^1.1.5",
    "express": "^4.17.1"
  }
}

O campo -k é obrigatório, serve para obter seus planos de teste na aplicação e que os relatórios sejam enviados para reportfy.

O campo -s é obrigatório, serve para obter a aplicação inicial e executá-la para iniciar os testes localmente.

O campo -ac é obrigatório, chave secreta para leitura de dados que contém criptografia da sua área de trabalho(workspace).

O campo -se é obrigatório, chave secreta para leitura de dados que contém criptografia da sua área de trabalho(workspace).

Os frameworks que estão disponíveis para rodar localmente são:

Clientes

Configurações de frameworks são diferenciadas para cada um, segue abaixo configuração simples de cada framework com as suas particularidades.

Koa

Exemplo base para criação de uma api no framework koa.

Iniciando o projeto.

$ npm init

Instalando dependências

Com npm.

$ npm install koa koa-body koa-router @reportfy/tester --save

Com yarn.

$ yarn add koa koa-body koa-router @reportfy/tester

Arquivo index.js para inicializar o projeto.

const Koa = require('koa');
const koaBody = require('koa-body');
const app = new Koa();

const Router = require('koa-router');


app.use(koaBody());


// Prefix all routes with: /books
const router = new Router({
    prefix: '/api'
});


router.get('/user', (ctx, next) => {
    ctx.body = {name: 'hello world'}
    next();
});

// Use the Router on the sub route /books
app.use(router.routes());

app.listen(3000);

module.exports = app

Executando os testes.

$ npx reportfy -k sua_chave_aqui' -ac 'access_key', -se 'secret_key' -s  index.js -k koa

Express

Exemplo base para criação de uma api no framework express.

Iniciando o projeto.

$ npm init

Instalando dependências

Com npm.

$ npm install express @reportfy/tester --save

Com yarn.

$ yarn add express @reportfy/tester

Arquivo index.js para inicializar o projeto.

const express = require('express')
const app = express()

app.use(express.json({}))

app.post('/api/user', (req, res) => {
    res.status(200).json(req.body)
})

app.get('/api/user/:name', (req, res) => {
    res.status(200).json()
})

app.listen(3000, () => console.log('listening http://localhost:3000'))

module.exports = app

Executando os testes.

$ npx reportfy -k sua_chave_aqui' -ac 'access_key', -se 'secret_key' -s  index.js  -k express

HapiJS

Exemplo base para criação de uma api no framework HapiJS.

Iniciando o projeto.

$ npm init

Instalando dependências

Com npm.

$ npm install @hapi/hapi @reportfy/tester --save

Com yarn.

$ yarn add @hapi/hapi @reportfy/tester

Arquivo index.js para inicializar o projeto.

const Hapi = require('@hapi/hapi')

const server = Hapi.server({
    port: 3000,
    host: 'localhost'
});

server.route({
    method: 'POST',
    path: '/api/user',
    handler: (request, reply) => {
        return request.payload
    }
});


server.start();

module.exports = server

Executando os testes.

$ npx reportfy -k sua_chave_aqui' -ac 'access_key', -se 'secret_key' -s  index.js  -k hapijs

Restify

Exemplo base para criação de uma api no framework restify.

Iniciando o projeto.

$ npm init

Instalando dependências

Com npm.

$ npm install restify @reportfy/tester --save

Com yarn.

$ yarn add restify @reportfy/tester

Arquivo index.js para inicializar o projeto.

const restify = require('restify');
const server = restify.createServer();

server.get('/api/user', (req, res) => {
    return res.send()
});

server.post('/api/user', (req, res) => {
    return res.send()
});

module.exports = server;

Executando os testes.

$ npx reportfy -k sua_chave_aqui' -ac 'access_key', -se 'secret_key' -s  index.js -k restify