Made test timeout to be configurable by setting KNEX_TEST_TIMEOUT environment variable.

This commit is contained in:
Mikael Lepistö 2016-06-14 19:02:43 +03:00
parent 6c157a1e3d
commit cd28114067
4 changed files with 16 additions and 3 deletions

View File

@ -21,7 +21,7 @@ notifications:
email: false
env:
- CXX=g++-4.8
- CXX=g++-4.8 KNEX_TEST_TIMEOUT=60000
addons:
postgresql: '9.4'

View File

@ -3096,6 +3096,15 @@ $ npm test
replacing with the path to your config file, and the config file is valid, the test suite should run properly.
</p>
<b class="header">My tests are failing because slow DB connection and short test timeouts! How to extend test timeouts?</b><br />
Some times e.g. with running CI on travis test suites default timeout 5seconds might be too short. The test suite looks from an environment variable
called <tt>KNEX_TEST_TIMEOUT</tt> for milliseconds how long each test might run before timing out.
</p>
<pre>
$ export KNEX_TEST_TIMEOUT=30000
$ npm test
</pre>
<p id="faq-nonode">
<b class="header">Can I use Knex outside of Node.js</b><br />
Yes. While the WebSQL spec is deprecated, there is still an adapter that provides support.

View File

@ -55,10 +55,10 @@
"coveralls": "cat ./test/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"dev": "babel -L -D -w src/ --out-dir lib/",
"lint": "eslint src/**",
"plaintest": "mocha --check-leaks -t 10000 -b -R spec test/index.js && npm run tape",
"plaintest": "mocha --check-leaks -b -R spec test/index.js && npm run tape",
"prepublish": "npm run build",
"tape": "node test/tape/index.js | tap-spec",
"test": "npm run lint && npm run babel && istanbul --config=test/.istanbul.yml cover node_modules/mocha/bin/_mocha -- --check-leaks -t 5000 -b -R spec test/index.js && npm run tape && (npm run build && echo BUILD TEST OK || echo BUILD TEST FAILED)"
"test": "npm run lint && npm run babel && istanbul --config=test/.istanbul.yml cover node_modules/mocha/bin/_mocha -- --check-leaks -b -R spec test/index.js && npm run tape && (npm run build && echo BUILD TEST OK || echo BUILD TEST FAILED)"
},
"bin": {
"knex": "./lib/bin/cli.js"

View File

@ -18,6 +18,8 @@ global.d = new Date();
Promise.longStackTraces();
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')('maria')
@ -29,5 +31,7 @@ describe('Query Building Tests', function() {
})
describe('Integration Tests', function() {
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
require('./integration')
})