Skip to content

Latest commit

 

History

History
119 lines (83 loc) · 3.03 KB

LEEME.md

File metadata and controls

119 lines (83 loc) · 3.03 KB

backend-tester

Marco de pruebas para backend-plus

designing npm-version downloads build outdated-deps

idioma: castellano también disponible en: Inglés

Instalación

$ npm install backend-tester

Objetivo principal

Tener una manera de hacer casos de prueba para sistemas basados en backend-plus

Work in progress

Ejemplo de uso

Para los ejemplos suponemos que la aplicación está en ./src/server. Los tests estarán entonces en ./src/test.

test.ts

"use strict";

// import the backend-plus App beeing tested:
import { AppPrincipal } from '../server/app-principal';

// import the needed functions and clasess from the test suite:
import { startServer, Session } from "backend-tester";

// the way to describe expected types
import { is } from "guarantee-type";

describe("main tests", function(){
    var server: AppPrincipal;    // eslint-disable-line no-var
    before(async function(){
        this.timeout(4000);
        server = await startServer(new AppPrincipal());
        await session.login({
            username: 'user4test',
            password: 'Pass1234!long-enough',
        });
    });
    after(async function(){
        this.timeout(3000);
        await server.shootDownBackend()
    })

    const personDescription = is.object({
        person_id: is.number,
        name: is.string,
        age: is.number
    });

    it("inserts a new person and set the defaults", async function(){
        // ACT
        const row = await session.saveRecord('person', {name: 'Taylor Taylor', age:44}, personDescription);
        // ASSERT
        assert.ok(row.person_id > 0);
        assert.equal(row.name, 'TAYLOR TAYLOR');
    })

Licencia

MIT