Skip to content

Parallel testing using the new globalSetup feature #6063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ojongerius opened this issue Apr 25, 2018 · 4 comments
Closed

Parallel testing using the new globalSetup feature #6063

ojongerius opened this issue Apr 25, 2018 · 4 comments

Comments

@ojongerius
Copy link

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

What is the current behavior?
If there are more than 1 tests, running Jest with--runInBand will succeed, but without will fail.

▶ yarn jest
yarn run v1.5.1
$ /Users/ojongerius/repos/jest-bug/node_modules/.bin/jest

 RUNS  ./mongo-insert.test.js
 FAIL  ./mongo-aggregate.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'getConnectionString' of undefined

       9 |     console.log('Setup MongoDB Test Environment');
      10 |
    > 11 |     this.global.__MONGO_URI__ = await global.__MONGOD__.getConnectionString();
      12 |     this.global.__MONGO_DB_NAME__ = global.__MONGO_DB_NAME__;
      13 |
      14 |     await super.setup();

      at MongoEnvironment.setup (mongo-environment.js:11:57)

 FAIL  ./mongo-insert.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'getConnectionString' of undefined

       9 |     console.log('Setup MongoDB Test Environment');
      10 |
    > 11 |     this.global.__MONGO_URI__ = await global.__MONGOD__.getConnectionString();
      12 |     this.global.__MONGO_DB_NAME__ = global.__MONGO_DB_NAME__;
      13 |
      14 |     await super.setup();

      at MongoEnvironment.setup (mongo-environment.js:11:57)

Test Suites: 2 failed, 2 total
Tests:       0 total
Snapshots:   0 total
Time:        0.454s
Ran all test suites.
Teardown mongod
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c /Users/ojongerius/repos/jest-bug/node_modules/.bin/jest
Directory: /Users/ojongerius/repos/jest-bug
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/ojongerius/repos/jest-bug/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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.

Pull down https://github.com/ojongerius/jest-bug, running yarn test will fail and yarn test-inband will succeed.

What is the expected behavior?
Running more n+1 tests will succeed

Please provide your exact Jest configuration

module.exports = {
  globalSetup: './setup.js',
  globalTeardown: './teardown.js',
  testEnvironment: './mongo-environment.js'
};

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

▶ npx envinfo --preset jest
npx: installed 1 in 3.967s

  System:
    OS: macOS High Sierra 10.13.4
    CPU: x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  Binaries:
    Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
    Yarn: 1.5.1 - /usr/local/bin/yarn
    npm: 5.8.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
  npmPackages:
    jest: ^22.4.3 => 22.4.3
@ojongerius
Copy link
Author

This is a duplicate of #5731 but I thought I'd use the issue template and create a small repo for you folks to replicate this issue more easily.

ojongerius added a commit to freeCodeCamp/open-api that referenced this issue Apr 25, 2018
    Local tests need to be inband too, while
    jestjs/jest#6063 is still open.
@thymikee
Copy link
Collaborator

Can you repost this message in mentioned thread? I appreciate the effort, but let's keep this issue tracker clean :).
Closing as duplicate of #5731

@ojongerius
Copy link
Author

Sure, done.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants