1.0.0 • Published 4 years ago

@yishitec/test v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

@yishitec/test

Usage

npm i -D mocha
mkdir test
touch test/hooks.js
touch .gitignore
touch .env

.gitignore

.env

.env

DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=
DB_DATABASE=mydb
BASE_URL=http://localhost:3000

test/hooks.js

const { consts } = require('@yishitec/web/server');
const t = require('@yishitec/test');
const db = require('../server/clients/db');

before(async () => {
  consts.dbConfig = {
    host: consts.env.DB_HOST || 'localhost',
    port: consts.env.DB_PORT || 3306,
    username: consts.env.DB_USERNAME || 'root',
    password: consts.env.DB_PASSWORD || '123',
    database: consts.env.DB_DATABASE || 'mydb',
    debug: false,
  };
  await db.initDb();
  consts.db = db;
});

package.json

{
  "scripts": {
    "test": "mocha"
  }
}