Jest: Tests nested within describe unable to run

Created on 29 Apr 2018  路  6Comments  路  Source: facebook/jest

Do you want to request a _feature_ or report a _bug_?

Bug

What is the current behavior?

Using this test code,

image

Test nested within a describe block, whether using it or test does not run, I get this error:

image

If I add a simple non-nested test to the file, the output changes and that simple test is recognized, but not the nested test in the same file.

image

image

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

Should allow me to nest test or it within describe

Please provide your exact Jest configuration

Version: ^22.4.3

Config:

image

Run npx envinfo --preset jest in your project directory and paste the
results here

image

Most helpful comment

describe cannot be async. Put the asynchronous work you're doing into the test, or in a beforeEach/beforeAll

All 6 comments

describe cannot be async. Put the asynchronous work you're doing into the test, or in a beforeEach/beforeAll

@SimenB whether the test is async or not, jest is now failing when nesting tests. Why?

Code example?

I am also experiencing this.

describe('hi', () => { expect(true).toBe(true) } // this fails
test('hi', () => { expect(true).toBe(true) } // this passes

If I use a describe block instead, I would get a message stating that at least one test is required in the file. :(

@alaboudi Use test inside describe:

describe('booleans', () => {
  test('true is itself', () => {
    expect(true).toBe(true);
  });
});

Thanks @chaselal , that worked!

Was this page helpful?
0 / 5 - 0 ratings