aspnet / Templating

[Archived] ASP.NET Core templates for .NET CLI and Visual Studio. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
205 stars 79 forks source link

Tests fail when running "npm test" on React + Redux starter project #772

Closed gfox1984 closed 5 years ago

gfox1984 commented 6 years ago

Tested with .NET Core SDK 2.1.403:

  1. Create a new React + Redux app using "dotnet new reactredux"
  2. Open the project in Visual Studio 2017 (15.8.6)
  3. Run "npm run test" inside ClientApp

The test in App.test.js fails, see below:

PM> cd ClientApp
PM> npm run test

> clean@0.1.0 test C:\Users\guill\source\local\poc\react\clean\ClientApp
> react-scripts test --env=jsdom

 RUNS  ...App.test.js





 RUNS  ...App.test.js





 RUNS  ...App.test.js




npm :  FAIL  src\App.test.js
At line:1 char:1
+ npm run test
+ ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ( FAIL  src\App.test.js:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError


 RUNS  ...App.test.js
  ΓùÅ renders without crashing

    Invariant Violation: You should not use <Link> outside a <Router>

      at invariant (node_modules/invariant/invariant.js:42:15)
      at Link.render (node_modules/react-router-dom/Link.js:81:29)
      at finishClassComponent (node_modules/react-dom/cjs/react-dom.development.js:7873:31)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:7850:12)
      at beginWork (node_modules/react-dom/cjs/react-dom.development.js:8225:16)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:10224:16)
      at workLoop (node_modules/react-dom/cjs/react-dom.development.js:10288:26)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:542:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:581:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:438:27)
      at renderRoot (node_modules/react-dom/cjs/react-dom.development.js:10366:7)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:11014:24)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:10967:7)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:10878:7)
      at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:10732:11)
      at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:10689:12)
      at scheduleTopLevelUpdate (node_modules/react-dom/cjs/react-dom.development.js:11193:5)
      at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:11231:7)
      at node_modules/react-dom/cjs/react-dom.development.js:15226:19
      at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:11102:12)
      at renderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:15225:17)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:15290:12)
      at Object.<anonymous>.it (src/App.test.js:7:22)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
          at <anonymous>





 RUNS  ...App.test.js





 RUNS  ...App.test.js
  × renders without crashing (15ms)




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


Watch Usage
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.
  console.error node_modules\fbjs\lib\warning.js:33
    Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
        in Link (at NavMenu.js:11)
        in NavbarBrand (at NavMenu.js:10)
        in div (created by NavbarHeader)
        in NavbarHeader (at NavMenu.js:9)
        in div (created by Grid)
        in Grid (created by Navbar)
        in nav (created by Navbar)
        in Navbar (created by Uncontrolled(Navbar))
        in Uncontrolled(Navbar) (at NavMenu.js:8)
        in Unknown (at Layout.js:9)
        in div (created by Col)
        in Col (at Layout.js:8)
        in div (created by Row)
        in Row (at Layout.js:7)
        in div (created by Grid)
        in Grid (at Layout.js:6)
        in Unknown (at App.js:9)
        in Unknown (at App.test.js:7)

  console.error node_modules\react-dom\cjs\react-dom.development.js:9747
    The above error occurred in the <Link> component:
        in Link (at NavMenu.js:11)
        in NavbarBrand (at NavMenu.js:10)
        in div (created by NavbarHeader)
        in NavbarHeader (at NavMenu.js:9)
        in div (created by Grid)
        in Grid (created by Navbar)
        in nav (created by Navbar)
        in Navbar (created by Uncontrolled(Navbar))
        in Uncontrolled(Navbar) (at NavMenu.js:8)
        in Unknown (at Layout.js:9)
        in div (created by Col)
        in Col (at Layout.js:8)
        in div (created by Row)
        in Row (at Layout.js:7)
        in div (created by Grid)
        in Grid (at Layout.js:6)
        in Unknown (at App.js:9)
        in Unknown (at App.test.js:7)

    Consider adding an error boundary to your tree to customize error handling behavior.
    Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
mkArtakMSFT commented 6 years ago

Thanks for contacting us, @gfox1984. @ryanbrandenburg, can you please handle this? Thanks! @gfox1984, would you be interested in submitting a PR to fix this?

mkArtakMSFT commented 6 years ago

This one is actually going to cover this: https://github.com/aspnet/Templating/issues/552

gfox1984 commented 6 years ago

Yeah actually my issue seems to be a duplicate of #539. I also noticed that App.test.js is now different in the master branch. So I'll give it another try when 2.2.0 is released. You may close this ticket.

ryanbrandenburg commented 5 years ago

We now run these tests as part of our functional tests and have seen no failures of this type. Closing as resolved. Please re-open with updated info if you still see this.