I am developing a NodeJS server app and have the following query.
Is there a Jest hook that exists that can check for a condition(s) and will only starts testing if true? If the condition is not true then the test process does not start and a message is displayed on console.
If not, then guess I could use package.json pre-script that will trigger a shell script that performs conditional check(s).
Places that are common to a group of tests can be used.
For a specific test group it's beforeAll
:
beforeAll(async () => {
...
if !(condition)
throw new Error('Condition not met');
});
For all test suites it's setup file:
module.exports = async () => {
...
if !(condition)
throw new Error('Condition not met');
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With