![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.
jest-t-assert
Advanced tools
Use tape style assertions with Jest. The assertions are very similar to AVA.
If you just want to migrate from AVA to Jest you should use jest-codemods instead.
import test from 'jest-t-assert';
test('a test case', t => {
t.true(2 < 10);
t.truthy(1);
t.not(2, '2');
t.deepEqual([1, 2], [1, 2]);
t.throws(() => {
throw new Error('This function throws');
});
t.snapshot({ a: 1, b: 'ok' });
});
You can also import t
directly if you only want to use the assertions without
the test
wrapper. This doesn't break existing tests that use Jest's callback
mode, where you call done()
, which is passed as the first argument to the
test function.
import { t } from 'jest-t-assert';
test('only using the assertions from `t`', () => {
t.true(2 < 10);
t.truthy(1);
t.not(2, '2');
t.deepEqual([1, 2], [1, 2]);
t.throws(() => {
throw new Error('This function throws');
});
t.snapshot({ a: 1, b: 'ok' });
});
Jest supports returning a promise from the test, so you can do the assertions in
the .then
calls.
import test from 'jest-t-assert';
test('promise resolves with the correct value', t => {
return Promise.resolve('value').then(val => t.is(val, 'value'));
});
test('using async/await', async t => {
const val = await Promise.resolve('value');
t.is(val, 'value');
// await directly
t.is(await Promise.resolve('value'), 'value');
});
If you need to use the callback mode you have to use test.cb
, which
requires you to end the test manually by calling t.end()
. It is highly
recommended to use promises and async / await
instead of the callback mode.
import test from 'jest-t-assert';
test.cb('a callback', t => {
t.plan(1);
setTimeout(() => {
t.pass();
t.end();
}, 2000);
});
test([title], fn)
Run a test. fn
will receive t
as the first argument, which provides the
assertions.
test.cb([title], fn)
Run a test in callback mode. fn
will receive t
, which provides the usual
assertions and additionally t.end()
, which must be called to manually end the
test. .cb
can be chained with any of modifiers listed below.
test.only([title], fn)
Only run this test. All other tests in the test suite are skipped.
test.skip([title], fn)
Skip the test. Useful to avoid a failing test without removing it or commenting it out.
test.after(fn)
Runs fn
after all tests in the test suite have completed.
test.afterEach(fn)
Runs fn
after each test in the test suite has completed.
test.before(fn)
Runs fn
before any test in the test suite is run.
test.beforeEach(fn)
Runs fn
before each test in the test suite is run.
t
The argument passed to the callback of test
, which is also exported as t
.
t.end()
End the test. This is only available when using test.cb
.
t.plan(count)
Plan how many assertions are used in the test. The test fails if the number of
assertions differs from count
.
t.pass()
An assertion that always passes.
t.fail()
An assertion that always fails.
t.true(actual)
Assert that actual
is true
.
t.false(actual)
Assert that actual
is false
.
t.truthy(actual)
Assert that actual
is truthy.
t.falsy(actual)
Assert that actual
is falsy.
t.is(actual, expected)
Assert that actual
is equal to expected
(based on ===
).
t.not(actual, expected)
Assert that actual
is not equal to expected
(based on ===
). The inverse
of t.is(actual, expected)
.
t.deepEqual(actual, expected)
Assert that actual
is deeply equal to expected
. This recursively checks the
equality of all fields.
t.notDeepEqual(actual, expected)
Assert that actual
is not deeply equal to expected
. This recursively checks
the equality of all fields. The inverse of t.deepEqual(actual, expected)
.
t.throws(fn, [error])
Assert that fn
throws an error. If error
is provided, the thrown error must
match it.
t.notThrows(fn)
Assert that fn
does not throw an error. The inverse of t.throws(fn)
.
t.regex(actual, regex)
Assert that actual
matches regex
.
t.notRegex(actual, regex)
Assert that actual
does not match regex
. The inverse of
t.regex(actual, regex)
.
t.snapshot(actual)
Assert that actual
matches the most recent snapshot.
FAQs
Use tape style assertions with Jest
The npm package jest-t-assert receives a total of 0 weekly downloads. As such, jest-t-assert popularity was classified as not popular.
We found that jest-t-assert 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.