Skip to content
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

preset config option not recognized when there are projects #6026

Closed
melissachang opened this issue Apr 18, 2018 · 4 comments
Closed

preset config option not recognized when there are projects #6026

melissachang opened this issue Apr 18, 2018 · 4 comments

Comments

@melissachang
Copy link

melissachang commented Apr 18, 2018

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

Bug

What is the current behavior?

preset property in project config is ignored. Repro steps:

npm install -g jest
git clone -b jest-6026 https://github.com/melissachang/repro-issues.git
cd repro-issues
npm install
jest

Test fails because preset in package.json is not recognized.

 FAIL   e2e  tests/e2e/test.js
  ● Test suite failed to run

    ENOENT: no such file or directory, open '/tmp/jest_puppeteer_global_setup/wsEndpoint'
      
      at PuppeteerEnvironment.setup (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:32:37)

package.json:

  "jest": {
    "projects": [
      {
        "displayName": "unit",
        "testMatch": [
          "<rootDir>/tests/unit/*.test.js"
        ]
      },
      {
        "displayName": "e2e",
        "preset": "jest-puppeteer",
        "testMatch": [
          "<rootDir>/tests/e2e/*.js"
        ]
      }
    ]
  }

What is the expected behavior?

preset should be recognized when running tests/e2e/test.js.

  • Move preset out of projects:
  "jest": {
    "projects": [
      "preset": "jest-puppeteer",
      {
        "displayName": "unit",
        "testMatch": [
          "<rootDir>/tests/unit/*.test.js"
        ]
      },
      {
        "displayName": "e2e",
        "testMatch": [
          "<rootDir>/tests/e2e/*.js"
        ]
      }
    ]
  }

jest still fails. preset is still not recognized when running tests/e2e/test.js.

  • Delete projects:
  "jest": {
    "preset": "jest-puppeteer"
  }

Finally, jest passes. preset is recognized.

There are several bugs, besides this one, with project configuration: #5938, #5597, #5441, #5260. I'm sure some subset are dupes.

Please provide your exact Jest configuration

jest: v22.4.3

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

/tmp/repro-issues (jest *): npx envinfo --preset jest
npx: installed 1 in 1.381s
(node:23443) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
    at e.darwin.process.platform.linux.process.platform.c.run.then.e (/usr/local/google/home/melchang/.npm/_npx/23443/lib/node_modules/envinfo/dist/cli.js:2:94297)
    at <anonymous>
(node:23443) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23443) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@nyssen
Copy link

nyssen commented Apr 23, 2018

I am facing the same problem. Using two projects, where one specified a jest-puppeteer preset, I can observe the following:

. ENOENT: no such file or directory, open '/var/folders/6l/y62_166d6bgby7fpd_rzgfwh0000gp/T/jest_puppeteer_global_setup/wsEndpoint'
   
at PuppeteerEnvironment.setup (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:32:37)

However, I only have one of the project configs making use of puppeteer and could work around the issue by listing it first.

@Prinzhorn
Copy link

Prinzhorn commented Jun 4, 2018

It looks like this is not an issue with the preset option itself. If I copy the preset config directly into the project configuration the same error happens

{
  "devDependencies": {
    "jest-environment-node": "^22.0.0",
    "jest-puppeteer": "^2.3.0",
    "puppeteer": "^1.3.0"
  },
  "jest": {
    "projects": [
      {
        "displayName": "unit",
        "testMatch": ["<rootDir>/tests/unit/*.test.js"]
      },
      {
        "displayName": "e2e",
        "globalSetup": "jest-environment-puppeteer/setup",
        "globalTeardown": "jest-environment-puppeteer/teardown",
        "testEnvironment": "jest-environment-puppeteer",
        "setupTestFrameworkScriptFile": "expect-puppeteer",
        "testMatch": ["<rootDir>/tests/e2e/*.js"]
      }
    ]
  }
}

@melissachang for me

Move preset out of projects:

works. Your example code is invalid JSON. If I move the preset out of the projects it does work. Which is confusing, because the unit tests do not work with the pupeteer preset. It looks like jest needs to know about the preset so it can be used inside the project config.

To be clear: with this JSON both tests run successfully.

{
  "devDependencies": {
    "jest-environment-node": "^22.0.0",
    "jest-puppeteer": "^2.3.0",
    "puppeteer": "^1.3.0"
  },
  "jest": {
    "preset": "jest-puppeteer",
    "projects": [
      {
        "displayName": "unit",
        "testMatch": [
          "<rootDir>/tests/unit/*.test.js"
        ]
      },
      {
        "displayName": "e2e",
        "preset": "jest-puppeteer",
        "testMatch": [
          "<rootDir>/tests/e2e/*.js"
        ]
      }
    ]
  }
}

@thymikee
Copy link
Collaborator

thymikee commented Jun 4, 2018

Duplicate of #6292

@thymikee thymikee marked this as a duplicate of #6292 Jun 4, 2018
@thymikee thymikee closed this as completed Jun 4, 2018
@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

4 participants