kentcdodds / testing-workshop

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

ReferenceError in master branch for test:react #77

Closed mikedloss closed 6 years ago

mikedloss commented 6 years ago

Environment info:

Problem description: Just starting the new FEM React Testing course, when running npm run test:react for the very first test, I get an error about an unknown plugin "syntax-dynamic-import".

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

    ReferenceError: Unknown plugin "syntax-dynamic-import" specified in "C:\\workspace\\react\\testing-workshop\\other\\configuration\\calculator.solution\\.babelrc.js" at 0, attempted to resolve relative to "C:\\workspace\\react\\testing-workshop\\other\\configuration\\calculator.solution" (While processing preset: "C:\\workspace\\react\\testing-workshop\\other\\configuration\\calculator.solution\\.babelrc.js")

      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
          at Array.map (<anonymous>)
      at Function.normalisePlugins (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
      at OptionManager.mergeOptions (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
          at Array.map (<anonymous>)
      at OptionManager.resolvePresets (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
      at OptionManager.mergePresets (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
      at OptionManager.mergeOptions (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.096s
Ran all test suites related to changed files.

Continuing on - I don't see any of the 4 babel plugins found in \other\configuration\calculator.solution\.babelrc.js, so I added them myself. This time, a different error comes up after running npm run test:react

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

    ReferenceError: [BABEL] C:\workspace\react\testing-workshop\other\simple-react\__tests__\item-list.todo.js: Unknown option: C:\workspace\react\testing-workshop\node_modules\react\index.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.

    A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

    Invalid:
      `{ presets: [{option: value}] }`
    Valid:
      `{ presets: [['presetName', {option: value}]] }`

    For more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options. (While processing preset: "C:\\workspace\\react\\testing-workshop\\node_modules\\react\\index.js") (While processing preset: "C:\\workspace\\react\\testing-workshop\\other\\configuration\\calculator.solution\\.babelrc.js")

      at Logger.error (../../node_modules/babel-core/lib/transformation/file/logger.js:41:11)
      at OptionManager.mergeOptions (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
          at Array.map (<anonymous>)
      at OptionManager.resolvePresets (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
      at OptionManager.mergePresets (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
      at OptionManager.mergeOptions (../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at ../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.412s
Ran all test suites related to changed files.

Not sure what to do - any guidance would be appreciated!

kentcdodds commented 6 years ago

Make sure to npm install in the /other/configuration/calculator.solution directory. That directory should be entirely self-contained and should work on its own. The setup script should automatically install everything, but if something went wrong in the install step then you could be facing some issues.

I'm afraid I can't offer much more support. Good luck!

mikedloss commented 6 years ago

That worked just fine for me, thank you!