backend-tester
v0.1.1
Published
Test suite for backend-plus
Downloads
5
Readme
backend-tester
Test suite for backend-plus
Install
$ npm install backend-tester
Main goal
Have a way to test systems based in backend-plus
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');
})