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.

Argument 'done' is missing inside test.concurrent

See original GitHub issue

Do you want to request a feature or report a bug?

Feature

What is the expected behavior?

I’d like to be able to use done inside async concurrent tests. Here’s my use case:

import { execFile } from 'child-process-promise';

const pathToMyAwesomeCli = '...';
const projectDirs = ['...', '...'];

describe('my-awesome-cli', () => {
  projectDirs.forEach((projectDir) => {
    test(`correctly works for case project \`${projectName}\``, async (done) => {
      try {
        await execFile(pathToMyAwesomeCli, [], { cwd: projectDir });
        done();
      } catch ({ code }) {
        done.fail(`non-zero exit code ${code}`);
      }
    })
  })
})

The above simplified example works great, but unfortunately the tests execute one after another. When I replace test with test.concurrent to have multiple execFile working in parallel, the done argument is no longer available. This means that I cannot use done() or done.fail() inside a concurrent test. It’d be great if test.concurrent and done could work together.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

jest v22.1.4, node v9.4.0, yarn 1.3.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Nov 16, 2019

You can do .length on the function btw to count number of arguments. You don’t need toString. That’s how jest itself detects if a done callback should be injected or not

Will definitely involve myself

Wonderful! PRs and issues are most welcome 🙂

0reactions
github-actions[bot]commented, May 11, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Globals - Jest
concurrent is considered experimental - see here for details on missing features and other issues. Use test.concurrent if you want the test to ......
Read more >
Testing multiple missing arguments - Stack Overflow
I think there are a couple of quirks. You're calling missing from within another function, it may mix up names and character values...
Read more >
How to Test Asynchronous Code with Jest | Pluralsight
In this guide, we will explore the different ways Jest give us to test ... Since the test function defines the done parameter,...
Read more >
Testing Python in Visual Studio Code
Unit tests are concerned only with the unit's interface—its arguments and return values—not with its implementation (which is why no code is shown...
Read more >
Test splitting and parallelism - CircleCI
circleci/config.yml file. The parallelism key specifies how many independent executors are set up to run the job. To run a job's steps in...
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