Jest: Jest 23 throws errors on `test` cases without a callback defined

Created on 24 May 2018  路  4Comments  路  Source: facebook/jest

馃悰 Bug Report

The latest version of Jest (23) now throws errors on test statements without a callback.

To Reproduce

Create a test file with the following in it:

describe('my-tests', () => {
   test('requires testing');
});

Expected behavior

Tests without a callback are marked as "pending" and do not throw errors.


We very, very commonly write out test cases before implementing the tests. These serve as reminders, or as a plan, of what the functional code we are going to write should actually do. With the latest changes in Jest 23, all of these throw errors now and our test suite fails.

Please revert this change or make this behavior toggleable.

Most helpful comment

That is a terrible design. You have thrown a wrench in anyone who implements Test-Driven Development (TDD).

Please reopen this bug as a feature request to make this configurable.

All 4 comments

This is by design, see #5558. You can do test.skip('bla bla', () => {}) and it should serve the same purpose

That is a terrible design. You have thrown a wrench in anyone who implements Test-Driven Development (TDD).

Please reopen this bug as a feature request to make this configurable.

@goyney the change seems a bit over the top (ensuring the the second arg was undefined or a function seems fine to me), but I'm happy enough with the test.skip() workaround provided - seems fine for TDD.

@goyney I'm sorry that this breaks your workflow, but it's not really fair to call it "terrible design".

Nevertheless, we're happy to see someone revert and replace as a lint rule (see comment here)

Was this page helpful?
0 / 5 - 0 ratings