server-side tests settings and e2e settings
This commit is contained in:
parent
9c80cd8466
commit
0cc707bc2c
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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();
|
|
@ -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);
|
||||
});
|
|
@ -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;
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
describe('description', () => {
|
||||
it('should ...', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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));
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue