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

0.1.1 • Public • Published

backend-tester

Test suite for backend-plus

designing npm-version downloads build outdated-deps

language: English also available in: Spanish

Install

$ npm install backend-tester

Main goal

Have a way to test systems based in backend-plus

Work in progress

Usage

Assuming the app is in ./src/server, the test will be in ./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');
    })

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i backend-tester

Weekly Downloads

3

Version

0.1.1

License

MIT

Unpacked Size

22.1 kB

Total Files

6

Last publish

Collaborators

  • tute