/
index.js
99 lines (82 loc) · 2.64 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* eslint-disable no-console */
'use strict';
require('source-map-support').install();
global.sinon = require('sinon');
const chai = (global.chai = require('chai'));
chai.use(require('sinon-chai'));
chai.should();
const bluebird = require('bluebird');
global.expect = chai.expect;
global.d = new Date();
bluebird.longStackTraces();
// '.timeout(ms, {cancel: true}) should throw error if cancellation cannot acquire connection' produced unhandled rejection and it's unclear how to avoid that
const EXPECTED_REJECTION_COUNT = 2;
const rejectionLog = [];
process.on('unhandledRejection', (reason) => {
console.error('Unhandled rejection:', reason);
rejectionLog.push({
reason,
});
});
process.on('exit', (code) => {
if (rejectionLog.length) {
console.error(`Unhandled rejections: ${rejectionLog.length}`);
rejectionLog.forEach((rejection) => {
console.error(rejection);
});
if (rejectionLog.length > EXPECTED_REJECTION_COUNT) {
process.exitCode = code || 1;
}
}
console.log('No unhandled exceptions');
});
describe('Util Tests', function() {
// Unit Tests for utilities.
require('./unit/query/string');
});
describe('Query Building Tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./unit/query/builder');
require('./unit/schema/mysql')('mysql');
require('./unit/schema/mysql')('mysql2');
require('./unit/schema/postgres');
require('./unit/schema/redshift');
require('./unit/schema/sqlite3');
require('./unit/schema/oracle');
require('./unit/schema/mssql');
require('./unit/schema/oracledb');
require('./unit/migrate/migration-list-resolver');
require('./unit/seed/seeder');
// require('./unit/interface'); ToDo Uncomment after fixed
require('./unit/knex');
});
describe('Integration Tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./integration');
});
const config = require('./knexfile');
if (config.oracledb) {
describe('Oracledb driver tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./unit/dialects/oracledb');
});
}
if (config.postgres) {
require('./unit/dialects/postgres');
}
if (config.sqlite3) {
describe('Sqlite driver tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./unit/dialects/sqlite3');
});
}
describe('CLI tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./cli/help.spec');
require('./cli/knexfile-test.spec');
require('./cli/migrate.spec');
require('./cli/migrate-make.spec');
require('./cli/seed.spec');
require('./cli/seed-make.spec');
require('./cli/version.spec');
});