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

Jest doesn't work with Parcel out of the box, as the docs suggest #11308

Closed
provegard opened this issue Apr 16, 2021 · 11 comments
Closed

Jest doesn't work with Parcel out of the box, as the docs suggest #11308

provegard opened this issue Apr 16, 2021 · 11 comments

Comments

@provegard
Copy link

🐛 Bug Report

The Getting Started page states:

Jest can be used in projects that use parcel-bundler to manage assets, styles, and compilation similar to webpack. Parcel requires zero configuration. Refer to the official docs to get started.

This implies (to me) that Parcel can do preprocessing before Jest runs, and that I don't need to do anything to make it work. However, this does not seem to be the case. When I run Jest with some files that use import and export, I get:

    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { jsSum } from "../src/js";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

Parcel can build the code without problem.

The linked Parcel documentation is not helpful AFAICS.

To Reproduce

  1. Clone git@github.com:provegard/jest-test.git
  2. Run npm install
  3. Run npm test

Expected behavior

Jest uses Parcel to bundle/preprocess before running tests.

@ahnpnl
Copy link
Contributor

ahnpnl commented Apr 17, 2021

I think Jest doc needs a guide like this https://jestjs.io/docs/webpack

@provegard
Copy link
Author

I think Jest doc needs a guide like this https://jestjs.io/docs/webpack

Correct me if I'm wrong, but that guide doesn't seem to show how to use Webpack and Jest together, but rather how to translate Webpack config to Jest config, no?

@ahnpnl
Copy link
Contributor

ahnpnl commented May 2, 2021

I’ve never tried that guide tbh. Perhaps you should ask in Jest Discord community to get help. This is not something provided out-of-the-box so I don’t think it is a Jest issue.

@provegard
Copy link
Author

I'd say that the fact that Jest has documentation that is incorrect and/or misleading is a Jest issue.

In this particular case, the person who wrote the following supposedly meant to link to something useful:

Refer to the official docs to get started.

However, as far as I can tell the official Parcel docs are not useful when it comes to using Jest with Parcel, so I think one of two actions are appropriate:

  1. Link to something useful.
  2. Remove the unhelpful documentation.

Don't you agree?

@SimenB
Copy link
Member

SimenB commented May 3, 2021

I've never used Parcel, so I'm not the person to update it. I think ideally we'd figure out what is needed and then update the guide. Would you be up for that?

I'm also happy to just remove it seeing as it's currently somewhat misleading.

#10211 (comment)

/cc @gkanishk

@gkanishk
Copy link
Contributor

gkanishk commented May 8, 2021

Hey @SimenB , I can work on documentation. We need to config babel along with parcel to work along with jest

@provegard
Copy link
Author

Hey @SimenB , I can work on documentation. We need to config babel along with parcel to work along with jest

👍 I wouldn't know what to write anyway - I'm using parcel and jest and they both work fine, independently of each other.

@gkanishk
Copy link
Contributor

Hey @SimenB , I can work on documentation. We need to config babel along with parcel to work along with jest

👍 I wouldn't know what to write anyway - I'm using parcel and jest and they both work fine, independently of each other.

will start working once I get assigned
cc. @SimenB

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label May 12, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@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 Jul 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants