![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Enable rollback for your tests that use knex.
Knest works with most test frameworks out there.
npm install knest --save-dev
Example using mocha as the testing framework
This example is part of the knex mocha tests. They can be run using the following npm script.
const assert = require('assert')
const {
mysql,
users,
resetDatabase,
findUsers,
createUsers,
createUser
} = require('./index.spec')
const knest = require('./index').bind(null, mysql)
describe('Mocha & Knest', () => {
it('should reset the database user table', () => resetDatabase(mysql))
it('should create user in user table', () =>
knest(trx =>
createUser(trx, users[0]).then(record => {
assert.strictEqual(record.name, users[0].name)
assert.strictEqual(record.email, users[0].email)
})
))
it('should create users using multiple transactions', () =>
knest(trx => createUsers(trx, users)))
it('should have rolled back all the insert queries', () =>
findUsers(mysql).then(result => assert.deepStrictEqual(result, [])))
after(() => process.exit())
})
Knest exports a single function.
What Knest basically does is wrap the test function and adds a knex transaction as the first argument of the test callback function.
returns a promise which will rollback the transaction when it resolves. This is required. Throws if a promise is not returned.
This value should be a knex-connection or a knex transaction object.
The testFn is called when the tests are run. It is called with the following arguments
knexTransaction is an instance of a knex transaction that uses the previously configured knex connection.
Knest is tested using MySQL. Make sure you have MySQL installed. The
./setup.sql
file makes it easy to setup a database and user for running the
tests.
sudo mysql -p < setup.sql
Then install, prune and run the tests.
{ npm i && npm prune; } > /dev/null
npm t
> knest@1.1.3 test
> npx standard && npm run test-tape && npm run test-mocha
> knest@1.1.3 test-tape
> tape index.tape.spec.js
TAP version 13
# should reset the database user table
# should create user in user table
ok 1 should be loosely deeply equivalent
# should create users using multiple transactions
# should have rolled back all the insert queries
ok 2 should be loosely deeply equivalent
1..2
# tests 2
# pass 2
# ok
> knest@1.1.3 test-mocha
> mocha index.mocha.spec.js
Mocha & Knest
✔ should reset the database user table (115ms)
✔ should create user in user table
✔ should create users using multiple transactions
✔ should have rolled back all the insert queries
Feel free to contribute in whatever way you deem to be valuable.
Read more in the CONTRIBUTING.md
FAQs
Rollback db after knex test finishes
We found that knest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.