MikeTheCanuck / WhoDidITalkTo

What's their name again? Where did I last see that person, and what did we talk about?
1 stars 1 forks source link

Add smoke tests #105

Open MikeTheCanuck opened 6 years ago

MikeTheCanuck commented 6 years ago

Each of the React Components should include the kinds of smoke tests prescribed by Facebook here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components

MikeTheCanuck commented 6 years ago

Implementing the second test to App.test.js meant installing and configuring enzyme per the instructions here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components

That is:

yarn add enzyme enzyme-adapter-react-16 react-test-renderer

And adding the basic configuration for src/setupTests.js.

MikeTheCanuck commented 6 years ago

However, Travis caught an error in just this configuration, which wasn't observed in local testing:

12.11s$ yarn test
yarn test v0.27.5
$ react-scripts test --env=jsdom
 PASS  src/components/NewEncounter.test.js
 FAIL  src/App.test.js
  ● <App /> › should render its children
    TypeError: Cannot read property 'eql' of undefined

      at Object.it (src/App.test.js:20:42)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)
Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 2 passed, 3 total
Snapshots:   0 total
Time:        9.149s
Ran all test suites.
error Command failed with exit code 1.
MikeTheCanuck commented 6 years ago

Question: should the enzyme* dependencies be listed in dependencies or in devDependencies? I'm seeing conflicting indications between these two resources: http://airbnb.io/enzyme/ https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components