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

Feature/resolve test error #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ksakiyama
Copy link

@ksakiyama ksakiyama commented Sep 9, 2018

Hi, @clintonwoo,
Thanks for your awesome React app🎉

This app has two errors on executing npm test. I fixed them. If you like these changes, please merge this Pull Request😀

1. Jest setting is missing

I ran npm test and got the following message.

SecurityError: localStorage is not available for opaque origins

Test Suites: 42 failed, 42 total
Tests:       0 total
Snapshots:   0 total
Time:        1.347s, estimated 4s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

I think that Jest settings are missing. I added "testEnvironment": "node" parameter to package.json.

2. fail to initialize Apollo for testing

After setting testEnvironment, I run npm test again and got the following error message. this.props.serverState.apollo.data isn't initialized.

TypeError: Cannot read property 'data' of undefined

Test Suites: 26 failed, 16 passed, 42 total
Tests:       26 failed, 43 passed, 69 total
Snapshots:   9 passed, 9 total
Time:        4.134s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

I'm not sure is this a coding mistake? I switched to {} from this.props.serverState.apollo.data. I don't know if this chage is a correct fix.

finally

After fixing them, all test passed!

Test Suites: 42 passed, 42 total
Tests:       69 passed, 69 total
Snapshots:   9 passed, 9 total
Time:        3.088s
Ran all test suites.

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

1 participant