make test individually runable

previously when you do something like mocha test/model.test.js
you would get an error like "assert is not a function"
This commit is contained in:
David Cheung 2016-10-21 11:17:02 -04:00
parent a0bc204159
commit b3c43b60cd
5 changed files with 19 additions and 9 deletions

View File

@ -16,7 +16,11 @@ Token.attachTo(ds);
var ACL = loopback.ACL;
describe('loopback.token(options)', function() {
beforeEach(createTestingToken);
var app;
beforeEach(function(done) {
app = loopback();
createTestingToken.call(this, done);
});
it('should populate req.token from the query string', function(done) {
createTestAppAndRequest(this.token, done)
@ -428,7 +432,9 @@ describe('AccessToken', function() {
});
describe('app.enableAuth()', function() {
var app;
beforeEach(function setupAuthWithModels() {
app = loopback();
app.enableAuth({ dataSource: ds });
});
beforeEach(createTestingToken);

View File

@ -16,11 +16,15 @@ var expect = require('chai').expect;
var it = require('./util/it');
describe('app', function() {
var app;
beforeEach(function() {
app = loopback();
});
describe.onServer('.middleware(phase, handler)', function() {
var app, steps;
var steps;
beforeEach(function setup() {
app = loopback();
steps = [];
});

1
test/mocha.opts Normal file
View File

@ -0,0 +1 @@
--require ./test/support.js

View File

@ -4,12 +4,16 @@
// License text available at https://opensource.org/licenses/MIT
var async = require('async');
var chai = require('chai');
var describe = require('./util/describe');
var loopback = require('../');
var ACL = loopback.ACL;
var defineModelTestsWithDataSource = require('./util/model-tests');
var PersistedModel = loopback.PersistedModel;
var sinonChai = require('sinon-chai');
var describe = require('./util/describe');
var expect = chai.expect;
chai.use(sinonChai);
describe('Model / PersistedModel', function() {
defineModelTestsWithDataSource({

View File

@ -12,7 +12,6 @@ expect = require('chai').expect;
loopback = require('../');
memoryConnector = loopback.Memory;
GeoPoint = loopback.GeoPoint;
app = null;
TaskEmitter = require('strong-task-emitter');
request = require('supertest');
var RemoteObjects = require('strong-remoting');
@ -21,10 +20,6 @@ var RemoteObjects = require('strong-remoting');
// for tests using the built-in User model
loopback.User.settings.saltWorkFactor = 4;
beforeEach(function() {
this.app = app = loopback();
});
assertValidDataSource = function(dataSource) {
// has methods
assert.isFunc(dataSource, 'createModel');