Releases: japa/core
Export types from subpath
Add "test.retryAttempt" property and add debug logs
Update dependencies and re-structure folder structure internally
Add isPinned property to test start and end event data
- feat: add "isPinned" property to test event data b1f1d47
Full Changelog: v7.2.0...v7.3.0
Add support for defining cleanup hooks within the test callback
In the following code example, if the select
query raises an exception, the cleanup code connection.destory
will never be called. Therefore, you will have an open connection even
after the test is over (aka failed).
test('find all users', async () => {
// Setup
const connection = await makeConnection()
// Test logic
await connection.select('*').from('users')
// Cleanup
await connection.destroy()
})
In order to counter situations like this, you can wrap the select query inside try/finally
block and close the connection inside the finally
block.
try {
await connection.select('*').from('users')
} finally {
await connection.destroy()
}
I usually avoid try/catch (whenever possible) because of the visual noise it creates. Therefore, this releases exposes a cleanup
function that you can use to define the cleanup handlers that always run regardless of the test passes or fails.
test('find all users', async ({ cleanup }) => {
const connection = await makeConnection()
/**
* Runs after the test is completed
*/
cleanup(() => connection.destroy())
await connection.select('*').from('users')
})
- feat: add support for defining cleanup hooks from within the test 2a8aa8f
Full Changelog: v7.1.0...v7.2.0
Allow reporters to have names
With this release, one can register a reporter with a name and a handler function as follows.
runner.registerReporter({
name: 'spec',
handler: () => {
}
})
What's Changed
- feat: ReporterContract can now be named by @Julien-R44 in #65
New Contributors
- @Julien-R44 made their first contribution in #65
Full Changelog: v7.0.1...v7.1.0
Update dependencies
- chore: update dependencies f4cfde2
- docs(README): remove v4 upgrade note b39378e
- docs(README): update japa.dev link 01b5efc
- chore: remove github health files in favor of central .github repo eb56a41
Full Changelog: v7.0.0...v7.0.1
Drill down layers when applying filters
Breaking change
After this release, creating a new instance of suite
will need a refiner instance. It does not impact the public API of @japa/runner
. But direct consumers of @japa/core
are impacted.
Improvements to the filters
Before this release, a group will run its hooks even when all the tests inside that group were filtered out (aka skipped). Similarly, a suite will run its hooks even when all the groups and its tests were filtered out.
Ideally, this does not impact the correctness of the tests. But still, you end up paying cost for running those hooks.
After this release, the upper layers have knowledge about their children and skip running themselves when children have been skipped/filtered out. For example:
- A suite will not run, if all the groups/tests within that group were filtered.
- A group will not run, if all the tests within that group were filtered.
Commits
Full Changelog: v6.0.7...v7.0.0
v6.0.7
Fix to not run lone tests when group filter is applied
This release contains a bug fix for not running lone tests when a group filter is applied. Let's say you have defined the following tests, where two of the tests are inside their respective groups and the third one is a lone test (without a group)
import { test } from '@japa/runner'
test.group('GroupOne', (group) => {
test('My Test', ({ assert }) => {
assert.isTrue(true)
})
})
test.group('GroupTwo', (group) => {
test('My Test', ({ assert }) => {
assert.isTrue(true)
})
})
test('Root', () => console.log('hey'))
Now when you run tests with the following filters, you would expect only the tests within the GroupOne
should run.
node bin/test.js --groups "GroupOne"
However, before this release, the lone test was also running.
Reference literal values in dynamic test titles
If you have a test using dataset with literal values, now you can reference the literal value using the special $self
keyboard. For example:
test('validate {$self}')
.with([
'[email protected]',
'[email protected]',
'[email protected]'
])
.run({ assert }, email) => {
assert.isTrue(validateEmail(email))
})
Earlier, there was no way to reference literal values from the dataset and that forces you to always use objects inside the dataset array.
Commits
- feat: allow referencing literal values in dynamic test title 9fd89cb
- fix: types breaking changes after moving for TypeScript 4.8 f23c4c4
- test: fix breaking test after fixing #63 86beab3
- docs(README): reference sponsors image from central CDN 6cb4278
- fix: do not run lone tests when group filter is applied 4429e20
- chore: update dependencies 6cad5c6
- chore: update dependencies 77363c0
- docs(README): add sponsors 4e48239
- test: remove only modifier and run all tests ae4d674
- chore: update dependencies 50738c2
Full Changelog: v6.0.6...v6.0.7
Fix super.emit to forward all arguments to parent class
- fix: pass all arguments to super.emit 369b8f3