2.0 KiB
How to contribute to Knex.js
-
Make changes in the
/srcdirectory and runnpm run babel(runs once and then quits) ornpm run dev(runs once and then watches for changes) to update the files in/lib.npm testwill also do this. -
Before sending a pull request for a feature or bug fix, be sure to have tests.
-
Use the same coding style as the rest of the codebase.
-
All pull requests should be made to the
masterbranch.
Integration Tests
The Easy Way
By default, Knex runs tests against MySQL (using mysql and mysql2), Postgres, and SQLite. The easiest way to run the tests is by creating the database 'knex_test' and granting permissions to the database's default username:
- MySQL: root
- Postgres: postgres
No setup is required for SQLite.
Specifying Databases
You can optionally specify which dialects to test using the DB environment variable. Values should be space separated and can include:
- mysql
- mysql2
- postgres
- sqlite3
- maria
- oracle
$ DB='postgres mysql' npm test
Custom Configuration
If you'd like to override the database configuration (to use a different host, for example), you can override the path to the default test configuration using the KNEX_TEST environment variable.
$ KNEX_TEST='./path/to/my/config.js' npm test
Creating Postgres User
Depending on your setup you might not have the default postgres user. To create a new user, login to Postgres and use the following queries to add the user. This assumes you've already created the knex_test database.
CREATE ROLE postgres WITH LOGIN PASSWORD '';
GRANT ALL PRIVILEGES ON DATABASE "knex_test" TO postgres;
Once this is done, check it works by attempting to login:
psql -h localhost -U postgres -d knex_test