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

add babel auto import to jest test section of config #193

Merged
merged 1 commit into from Mar 9, 2020

Conversation

thedavidprice
Copy link
Contributor

@peterp Continuing the work from #152 which I thought was working when testing locally (I think my yarn lock was keeping packages I had removed).

Previously, I tried to move the auto-import from Webpack to Babel, which worked for Jest but did not work for running the development environment. When I read your recent doc about where/how we build, it seems that Webpack only is how we're building the web/ side, and not our file core/config/babel-preset.js. Researching a bit further about babel, I think I now understand this code:

overrides: [
    // ** API **
    {
      test: './api/',
      presets: [
        [
          '@babel/preset-env',
          {
            targets: {
              node: TARGETS_NODE,
...

and this

 // ** WEB **
    {
      test: './web',
...

is effectively a switch to use the included settings only to transpile in the case Jest is being run.

Am I correct?

If so, the changes in this PR include adding the auto-import to the "Web" section of the babel config file. I've kept the auto-import settings in Webpack.

My local testing confirms the yarn rw test command now runs correctly (and passes) using the updated test templates in master redwood branch, which do not import React and gql implicitly. And the command yarn rw dev also runs as expected with no browser errors.

Are we there? Finally?!?

@thedavidprice thedavidprice self-assigned this Mar 8, 2020
@peterp peterp merged commit dca296a into master Mar 9, 2020
@thedavidprice thedavidprice deleted the dsp-jest-babel-config branch March 9, 2020 15:28
mohsen1 pushed a commit to mohsen1/redwood that referenced this pull request Apr 12, 2020
add babel auto import to jest test section of config
@thedavidprice thedavidprice added this to the unassigned-version milestone May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants