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

Add Jest for testing (if there is test folder) #93

Open
Sly777 opened this issue Aug 9, 2017 · 8 comments
Open

Add Jest for testing (if there is test folder) #93

Sly777 opened this issue Aug 9, 2017 · 8 comments

Comments

@Sly777
Copy link
Owner

Sly777 commented Aug 9, 2017

Add Jest for testing (if there is test folder)

https://facebook.github.io/jest/

Task Rules

  • If there is test folder on the root, Jest will run.
  • Example pages need to get tests
  • All settings should be inside of jest.config.js on root.
@bearcanrun
Copy link
Contributor

I started to tackle this then realized I jumped the gun by adding Jest AND Enzyme. Before I go further in this direction, is using just Jest preferred? Adding Enzyme has a few more twists and is explained in the started documentation Testing.md that you can read in my commit.

@mulyoved
Copy link

is using just Jest preferred

I think yes, I prefer using Jest with storyshots and don't use Enzyme

@Sly777
Copy link
Owner Author

Sly777 commented Oct 31, 2017

I think also Jest is enough for most of the scenarios. But if someone says the reason why it's should be, We can discuss. I'm not 100% sure.

@bearcanrun
Copy link
Contributor

We'll just go Jest then! Since getting Enzyme to work wasn't so straight forward, I'll add simple instructions for adding it in the docs.

@Sly777
Copy link
Owner Author

Sly777 commented Oct 31, 2017

perfect! @bearcanrun

@bearcanrun
Copy link
Contributor

So... I've run into a problem. Running Jest in the jsdom test environment throws breaking errors as reported in jsdom #1783. Though it says for ubuntu, I'm on a mac pro and get the same thing. When I change the testEnvironment under Jest config in package.json to 'node', then no problems at all. I realize jsdom is the more ideal testing environment.

First, is anyone willing to check to make sure it's not just me?

git clone -b add-jest --single-branch https://github.com/bearcanrun/ran.git
yarn install && yarn run setup
yarn run jest

If you get error TypeError: Cannot read property '_location' of null then change in package.json:

"jest": {
    ...
    "testEnvironment": "node"
  },

and again run yarn run jest.

Then, any thoughts on course of action? It's weird that I had no problems with Enzyme installed, but it allowed me to easily shallow render the components. With just Jest, you have to mock everything out, at least, for snapshotting pages.

@Sly777
Copy link
Owner Author

Sly777 commented Nov 14, 2017

Hey @bearcanrun, sorry I was not able to check comments on RAN last couple days. Should I test it or did u fix it?

@jaggad
Copy link

jaggad commented Mar 13, 2018

@bearcanrun Any progress on the jest test integration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants