added support of tsnode to run tests

This commit is contained in:
Umed Khudoiberdiev 2016-12-24 00:30:39 +05:00
parent fff04f10ea
commit 1aadaa0781
5 changed files with 53 additions and 10 deletions

View File

@ -332,6 +332,21 @@ export class Gulpfile {
.pipe(istanbul.writeReports());
}
/**
* Runs tests the quick way.
*/
@Task("ts-node-tests")
quickTests() {
chai.should();
chai.use(require("sinon-chai"));
chai.use(require("chai-as-promised"));
return gulp.src(["./test/**/*.ts"])
.pipe(mocha({
timeout: 10000
}));
}
@Task()
coverageRemap() {
return gulp.src("./coverage/coverage-final.json")

View File

@ -9,9 +9,17 @@ import {Category} from "./entity/Category";
* So we run tests only for mysql.
*/
describe("lazy-relations", () => {
const resourceDir = __dirname + "/../../../../../test/functional/lazy-relations/";
const userSchema = require(resourceDir + "schema/user.json");
const profileSchema = require(resourceDir + "schema/profile.json");
let userSchema: any, profileSchema: any;
try {
const resourceDir = __dirname + "/../../../../../test/functional/lazy-relations/";
userSchema = require(resourceDir + "schema/user.json");
profileSchema = require(resourceDir + "schema/profile.json");
} catch (err) {
const resourceDir = __dirname + "/";
userSchema = require(resourceDir + "schema/user.json");
profileSchema = require(resourceDir + "schema/profile.json");
}
let connections: Connection[];
before(async () => connections = await createTestingConnections({

View File

@ -10,10 +10,16 @@ import {Blog} from "./entity/Blog";
import {Category} from "./entity/Category";
describe("repository > basic methods", () => {
const resourceDir = __dirname + "/../../../../../../test/functional/repository/basic-methods/";
const userSchema = require(resourceDir + "schema/user.json");
let userSchema: any;
try {
const resourceDir = __dirname + "/../../../../../../test/functional/repository/basic-methods/";
userSchema = require(resourceDir + "schema/user.json");
} catch (err) {
const resourceDir = __dirname + "/";
userSchema = require(resourceDir + "schema/user.json");
}
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [Post, Blog, Category],

View File

@ -7,9 +7,16 @@ import {FindOptions} from "../../../../src/find-options/FindOptions";
import {User} from "./model/User";
describe("repository > find methods", () => {
const resourceDir = __dirname + "/../../../../../../test/functional/repository/find-methods/";
const userSchema = require(resourceDir + "schema/user.json");
let userSchema: any;
try {
const resourceDir = __dirname + "/../../../../../../test/functional/repository/find-methods/";
userSchema = require(resourceDir + "schema/user.json");
} catch (err) {
const resourceDir = __dirname + "/";
userSchema = require(resourceDir + "schema/user.json");
}
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [Post],

View File

@ -81,7 +81,14 @@ export function setupTestingConnections(options?: TestingOptions) {
let ormConfigConnectionOptionsArray: TestingConnectionOptions[] = [];
try {
ormConfigConnectionOptionsArray = require(__dirname + "/../../../../ormconfig.json");
try {
ormConfigConnectionOptionsArray = require(__dirname + "/../../../../ormconfig.json");
} catch (err) {
ormConfigConnectionOptionsArray = require(__dirname + "/../../ormconfig.json");
console.log(ormConfigConnectionOptionsArray);
}
} catch (err) {
throw new Error(`Cannot find ormconfig.json file in the root of the project. To run tests please create ormconfig.json file` +