kentcdodds / testing-workshop

A workshop for learning how to test JavaScript applications
http://git.io/testing-workshop
1.36k stars 710 forks source link

WIP: Adding babel plugins to devDeps & changing to babelrc.js #100

Closed melloc01 closed 5 years ago

melloc01 commented 5 years ago

Had to tweak the config & add change the package.json to make it work on my machine, really don't know how it was working for you guys :sweat_smile:

closes #93

melloc01 commented 5 years ago

Added WIP: prefix because it seems that Jest is not transforming JSX.

FAIL   react  other/simple-react/__tests__/item-list.todo.js
  ● Test suite failed to run

    /home/rafael/Studies/testing-workshop/other/simple-react/__tests__/item-list.todo.js: Unexpected token (45:9)

      Jest encountered an unexpected token
      This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
      By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
      Here's what you can do:
       • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
       • If you need a custom transformation specify a "transform" option in your config.
       • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
      You'll find more details and examples of these config options in the docs:
      https://jestjs.io/docs/en/configuration.html
      Details:
        43 |   const container = document.createElement('div')
        44 | 
      > 45 |   render(<ItemList items={['apple', 'orange', 'pear']} />, container)
           |          ^
        46 | 
        47 |   expect(container.textContent).toMatch('apple orange pear')
        48 | })

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.703s
Ran all test suites related to changed files.
kentcdodds commented 5 years ago

I'm no longer maintaining the master branch on this repository and the fem-2018 will now be the main branch. Thanks!