Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest not outputting describe names nor test names when more than one test file

TLDR

When running Jest (23.5.0) with only one file, it outputs 'describe names' and 'test names'. I want Jest to output 'describe names' and 'test names' when running with multiple test files, but it seems to be automatically suppressing.

TMI

Example:

 PASS  src/components/UsersTable.test.jsx
  UsersTable
    ✓ is a table (4ms)
    ✓ has columns 'first', 'last', 'email' (1ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        1.768s, estimated 2s
Ran all test suites.

When running with two, it suppresses. Example:

 PASS  src/components/UsersTableRow.test.jsx
 PASS  src/components/UsersTable.test.jsx

Test Suites: 2 passed, 2 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        2.254s
Ran all test suites.

Partial code sample:

describe('UsersTable', () => {
    const component = renderer.create(
        <UsersTable />
    );
    const usersTable = component.toJSON();

    test('is a table', () => {
        expect(usersTable.type).toBe('table');
    });

Removing 'test' from the name of either file such that only one of the two tests runs at a time, results in successful desired output of name details for either file. TLDR: Both files work alone.

like image 500
Geoffrey Hale Avatar asked Feb 04 '23 22:02

Geoffrey Hale


1 Answers

TLDR

Run jest with --verbose.

Change package.json test script to jest --verbose.

TMI

I tried npm run test --verbose which affected the output but didn't include the information I was hoping for. I mistakenly thought that --verbose wasn't the fix. But in npm run test --verbose, I'm mistakenly applying the verbose flag to the npm process, not to jest.

Apparently jest is the same as jest --verbose if only a single test file exists, but not for two or more. For two or more, must explicitly include --verbose.

like image 99
Geoffrey Hale Avatar answered Feb 06 '23 16:02

Geoffrey Hale