question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe, bail and each don't work as written in the doc

See original GitHub issue

šŸ› Bug Report

Describe doesn’t start a test suite, bail doesn’t stop the tests after a fail, each doesn’t format names correctly, and jest output is so verbose that it overflows my terminal.

To Reproduce

  • git clone https://github.com/Sharcoux/GoldMines.git
  • npm i
  • npm run test
  • Try to read the results of the tests

Expected behavior

describe

According to the documentation:

describe(name, fn) creates a block that groups together several related tests in one ā€œtest suiteā€.

This should start 2 tests suite:

    describe('test 1',() => {
      test('one space, one mine', () => {
        expect(findBestSpot(1, 1, 1, 1, [{"x":0,"y":0}])).toEqual({"coordinates":{"x":0,"y":0},"goldMines":1});
      });
    });
  
    describe('test 2',() => {
      test('one space, no mine', () => {
        expect(findBestSpot(1, 1, 1, 1, [])).toEqual({"coordinates":{"x":0,"y":0},"goldMines":0});
      });
    });

Actual result: => Test Suites: 1 failed, 1 total

bail

According to the documentation:

The bail config option can be used here to have Jest stop running tests after the first failure.

Running: npx jest -b

Actual result: => Tests: 23 failed, 10 passed, 33 total

How could 23 tests fail if jest did stop at first failure?

each

According to the documentation:

Generate unique test titles by positionally injecting parameters with printf formatting:

So this test’s name should be ā€˜name’, but instead, it’s name is ā€˜1’…

const A = [[1, 2, 3, "name"]];
test.each(A)('%s', (a,b,c) => expect(a+b).toBe(c));

Actual result:

 PASS  ./index.test.js
  āœ“ 1 (5ms)

By the way, ā€œ%4$sā€ doesn’t work either…

Link to repl or repo (highly encouraged)

A small repo with a single test file that perfectly illustrate the issue

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i7-5650U CPU @ 2.20GHz
  Binaries:
    Node: 8.9.2 - ~/.nvm/versions/node/v8.9.2/bin/node
    Yarn: 1.12.1 - ~/.yarn/bin/yarn
    npm: 6.3.0 - ~/.nvm/versions/node/v8.9.2/bin/npm
  npmPackages:
    jest: ^23.6.0 => 23.6.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:13
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
Sharcouxcommented, Nov 30, 2018

Sorry guys, but I slept on this, and it really bugs me.

When you decide to use an option to stop the tests after the first failure, in what kind of context would it be the expected behavior that it keeps failing all the tests in the current file?

Moreover, you are telling me that with jest, if I want to create 20 tests and I want the tests to stop at the first failure, my only choice is to create 20 test files?!

7reactions
dartandrevinskycommented, Dec 18, 2019

With all due respect (and do mean respect), Michal, the ā€˜collaborator’ badge that you and several other people sport here, suggests you are more capable to address this issue (with no need of assuming the offensive). I apologize if I sounded rude, sorry - I wanted to draw attention to this issue.

Apparently it is an issue - it was reported a year ago - there was an argument, yet the OP’s reasons seem to outweigh the responses. There is no working bail, no way to abruptly stop the tests - if it’s the part of the bigger design, maybe it should be shared? Or fixed accordingly?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describe, bail and each don't work as written in the doc #7434
According to the documentation: The bail config option can be used here to have Jest stop running tests after the first failure. Running:...
Read more >
What You Need to Know About Bail - The Legal Aid Society
Bail is an amount of money that some people charged with crimes have to pay in order to be released from jail while...
Read more >
GLOSSARY OF TERMS AND PHRASES RELATING TO BAIL ...
Primarily used with commercial bail bondsmen, consent of surety refers to a written document from the bondsman agreeing to remain as surety despite...
Read more >
Bail - How Courts Work
The purpose of bail is simply to ensure that defendants will appear for trial and all pretrial hearings for which they must be...
Read more >
What Is a Bail Bond? Definition, How It Works With Posting Bail
Suppose that New York resident Melissa has broken the law, and the court has set her bail at $25,000. Although Melissa doesn't want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found