2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00

test(REST): Initialize models before testing

This commit is contained in:
Faris Ansari 2018-09-14 23:16:30 +05:30
parent 06c06a81cb
commit 2950a368c0
2 changed files with 7 additions and 4 deletions

View File

@ -25,8 +25,6 @@ require.extensions['.html'] = function (module, filename) {
module.exports = fs.readFileSync(filename, 'utf8'); module.exports = fs.readFileSync(filename, 'utf8');
}; };
process.env.NODE_ENV = 'development';
module.exports = { module.exports = {
async start({backend, connectionParams, models, authConfig=null}) { async start({backend, connectionParams, models, authConfig=null}) {
await this.init(); await this.init();

View File

@ -4,23 +4,28 @@ const fetch = require('node-fetch');
const { spawn } = require('child_process'); const { spawn } = require('child_process');
const process = require('process'); const process = require('process');
const HTTPClient = require('frappejs/backends/http') const HTTPClient = require('frappejs/backends/http')
const utils = require('frappejs/utils');
const models = require('frappejs/models');
const common = require('frappejs/common');
// create a copy of frappe // create a copy of frappe
var test_server; var test_server;
describe('REST', () => { describe.only('REST', () => {
before(async function() { before(async function() {
test_server = spawn('node', ['tests/test_server.js'], { stdio: 'inherit' }); test_server = spawn('node', ['tests/test_server.js'], { stdio: 'inherit' });
await frappe.init(); await frappe.init();
await frappe.registerLibs(common);
await frappe.registerModels(models);
await frappe.login('Administrator'); await frappe.login('Administrator');
frappe.db = await new HTTPClient({server: 'localhost:8000'}); frappe.db = await new HTTPClient({server: 'localhost:8000'});
frappe.fetch = fetch; frappe.fetch = fetch;
// wait for server to start // wait for server to start
return await frappe.sleep(2); return await utils.sleep(2);
}); });
after(() => { after(() => {