server-side tests settings and e2e settings

This commit is contained in:
Carlos 2017-09-10 20:04:22 +02:00
parent 9c80cd8466
commit 0cc707bc2c
10 changed files with 145 additions and 10 deletions

View File

@ -0,0 +1,12 @@
import createNightmare from '../nightmare';
const nightmare = createNightmare();
describe('Clients path', () => {
it('should create a new client', done => {
// nightmare user to go any further.
nightmare.login('Nightmare', 'NightmarePassword')
.then(() => {
done();
});
});
});

39
e2e/e2e.js Normal file
View File

@ -0,0 +1,39 @@
require('babel-core/register')({presets: ['es2015']});
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
console.log(warning.stack);
});
var verbose = false;
if (process.argv[2] === '--v') {
verbose = true;
}
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.loadConfig({
spec_files: [
'./helpers.js',
'./**/*[sS]pec.js'
],
helpers: [
// to implement
// '/api/utils/jasmineHelpers.js'
]
});
jasmine.addReporter(new SpecReporter({
spec: {
// displayStacktrace: 'summary',
displaySuccessful: verbose,
displayFailedSpec: true,
displaySpecDuration: true
}
}));
jasmine.execute();

10
e2e/helpers.js Normal file
View File

@ -0,0 +1,10 @@
import Nightmare from 'nightmare';
Nightmare.action('login', function(name, password, done) {
this.goto('http://localhost:5000/auth/?apiKey=salix')
.wait('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input')
.type('body > vn-login > div > div > div > form > vn-textfield:nth-child(1) > div > input', name)
.type('body > vn-login > div > div > div > form > vn-textfield:nth-child(2) > div > input', password)
.click('input[type="submit"]')
.then(done);
});

22
e2e/nightmare.js Normal file
View File

@ -0,0 +1,22 @@
/* eslint no-console: 0 */
import Nightmare from 'nightmare';
import './helpers';
export default function createNightmare(width = 1100, height = 600) {
const nightmare = new Nightmare({show: true, typeInterval: 10}).viewport(width, height);
nightmare.on('page', function(type, message, error) {
fail(error);
});
nightmare.on('console', function(type, message) {
if (type === 'error') {
fail(message);
}
if (type === 'log') {
console.log(message);
}
});
return nightmare;
}

View File

@ -52,6 +52,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"merge-stream": "^1.0.1",
"nightmare": "^2.10.0",
"node-sass": "^3.11.0",
"nodemon": "^1.12.0",
"pre-commit": "^1.1.3",

View File

@ -0,0 +1,20 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,5 +0,0 @@
describe('description', () => {
it('should ...', () => {
expect(true).toBe(true);
});
});

View File

@ -0,0 +1,28 @@
var app = require('../../../../server/server');
var Client = app.models.Client;
describe('Client Create()', () => {
beforeEach(() => {
//wipe db
//insert firxtures
});
let data = {
name: 'John',
userName: 'John',
email: 'John@wayne.com',
fi: 'The Man',
socialName: 'Wayne industries'
}
it('should createa new account', (done) => {
Client.createUserProfile(data, (error) => {
//connect to db and query for the new account OR use accounts model to check it like this
app.models.Account.findOne({where: {name: 'John'}})
.then((account) => {
console.log(account);
done();
});
});
});
});

View File

@ -0,0 +1,8 @@
export function catchErrors(done) {
return error => {
if (error instanceof Error) {
return done.fail(error.stack);
}
return done.fail(JSON.stringify(error));
};
}

View File

@ -1,10 +1,10 @@
require('babel-core/register')({presets: ['es2015']});
// process.on('warning', warning => {
// console.log(warning.name);
// console.log(warning.message);
// console.log(warning.stack);
// });
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
console.log(warning.stack);
});
var verbose = false;